2015-12-13 04:42:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2017-10-22 15:02:43 +00:00
|
|
|
use DB;
|
|
|
|
use Illuminate\Database\SQLiteConnection;
|
2017-04-19 04:22:02 +00:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2015-12-13 04:42:28 +00:00
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2017-04-19 04:22:02 +00:00
|
|
|
// Fix utf8mb4-related error starting from Laravel 5.4
|
|
|
|
Schema::defaultStringLength(191);
|
|
|
|
|
2017-10-22 15:02:43 +00:00
|
|
|
// Enable on delete cascade for sqlite connections
|
|
|
|
if (DB::connection() instanceof SQLiteConnection) {
|
|
|
|
DB::statement(DB::raw('PRAGMA foreign_keys = ON'));
|
|
|
|
}
|
|
|
|
|
2015-12-13 04:42:28 +00:00
|
|
|
// Add some custom validation rules
|
2015-12-15 16:28:54 +00:00
|
|
|
Validator::extend('path.valid', function ($attribute, $value, $parameters, $validator) {
|
2015-12-14 13:22:39 +00:00
|
|
|
return is_dir($value) && is_readable($value);
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2017-05-10 09:49:12 +00:00
|
|
|
if (!$this->app->environment('production')) {
|
|
|
|
$this->app->register('Laravel\Tinker\TinkerServiceProvider');
|
|
|
|
$this->app->register('Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider');
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
}
|
|
|
|
}
|