mirror of
https://github.com/koel/koel
synced 2024-12-23 02:53:20 +00:00
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
|
|
use DB;
|
|
use Illuminate\Database\SQLiteConnection;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Laravel\Tinker\TinkerServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
// 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'));
|
|
}
|
|
|
|
// Add some custom validation rules
|
|
Validator::extend('path.valid', function ($attribute, $value, $parameters, $validator) {
|
|
return is_dir($value) && is_readable($value);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
if (!$this->app->environment('production')) {
|
|
$this->app->register(TinkerServiceProvider::class);
|
|
$this->app->register(IdeHelperServiceProvider::class);
|
|
}
|
|
}
|
|
}
|