koel/app/Providers/AppServiceProvider.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2015-12-13 04:42:28 +00:00
<?php
namespace App\Providers;
2018-08-22 17:59:14 +00:00
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
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;
2018-08-22 17:59:14 +00:00
use Laravel\Tinker\TinkerServiceProvider;
2015-12-13 04:42:28 +00:00
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')) {
2018-08-22 17:59:14 +00:00
$this->app->register(TinkerServiceProvider::class);
$this->app->register(IdeHelperServiceProvider::class);
}
2015-12-13 04:42:28 +00:00
}
}