koel/app/Providers/AppServiceProvider.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2015-12-13 04:42:28 +00:00
<?php
namespace App\Providers;
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);
// 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
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()
{
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
}
}