This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in Homestead and typical Ubuntu, put this in /etc/mysql/my.cnf | |
# right after explicit_defaults_for_timestamp | |
sql-mode = "ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" | |
# Also, if you execute .sql file from an older MySQL version, you might get errors befause the ROW_FORMAT=FIXED is no | |
# longer a valid option. Search all ROW_FORMAT=FIXED replace with ROW_FORMAT=DYNAMIC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function testIsForbiddenResponse() | |
{ | |
$obj = new class(){ | |
use \App\Http\Controllers\Traits\JsonMessagesTrait; | |
}; | |
$this->assertEquals(403, $obj->isForbiddenResponse()->getStatusCode()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE `tbl_name` SET | |
`first_name` = IF( | |
LOCATE(' ', `name`) > 0, | |
SUBSTRING(`name`, 1, LOCATE(' ', `name`) - 1), | |
`name` | |
), | |
`last_name` = IF( | |
LOCATE(' ', `name`) > 0, | |
SUBSTRING_INDEX(`name`, ' ' - 1), /* Changed line */ | |
NULL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Cego\Facades; | |
class URL extends \Illuminate\Support\Facades\URL | |
{ | |
public static function route($name, $parameters = array(), $absolute = true, $route = null) | |
{ | |
$urlGenerator = static::$app['url']; | |
/* @var \Illuminate\Routing\UrlGenerator $urlGenerator */ | |
$route = $urlGenerator->route($name, $parameters, $absolute, $route); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basically, we compile all view templates into a single ng.html template that our frontend app consumes. This app is currently in private development, so I can't give a link to demo it, but the process is simple: | |
1. Create a Command to process the relevant Blade templates and concatenate into a single static HTML file, with each view encapsulated in a <script type="text/html"> element. That static file gets served by webserver from the public directory, gzipped by server and cached by browser. Could be served via CDN. | |
2a. On dev machines, add a gulp watcher to call this command whenever a file within the view directory changes. | |
2b. On production, call the process command in deploy script. | |
In our case, we put all blade templates intended for the front end in app/views/angular -- this keeps other blade templates separate, such as email messages. | |
I've included 5 files here: | |
1. The actual Command script that processes the Angular view files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App::error(function(\Illuminate\Database\Eloquent\ModelNotFoundException $e){ | |
Log::error($e); | |
if (Request::ajax() or Request::is('api/*')) { | |
return Response::json(['flash'=>trans('application.resource_not_found')],404); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Sa\Services\Log; | |
class Logger extends \Monolog\Logger | |
{ | |
/** | |
* @param string $name The logging channel | |
* @param \Monolog\Handler\HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. | |
* @param callable[] $processors Optional array of processors | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace Sa\Services\Log; | |
use Illuminate\Log\LogServiceProvider as LaravelLogServiceProvider; | |
use Illuminate\Log\Writer; | |
class LogServiceProvider extends LaravelLogServiceProvider | |
{ | |
/** | |
* Register the service provider. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in my controller constructor, I apply a filter with arguments: | |
$this->beforeFilter('auth.hasRole:admin,staff,developer', ['except' => 'getLogoutas',]); | |
// in my global filters.php | |
/** | |
* Verify that the logged-in user has a specified role | |
*/ | |
Route::filter('auth.hasRole', function($route, $request, $value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Auth extends Laravel\Auth {} | |
/** | |
* @method static add(string $name, string $source, array $dependencies = array(), array $attributes = array()) | |
* @method static string styles() | |
* @method static string scripts() | |
*/ | |
class Asset extends Laravel\Asset {} | |
class Autoloader extends Laravel\Autoloader {} | |
class Bundle extends Laravel\Bundle {} |
NewerOlder