koel/app/Providers/AppServiceProvider.php
Phan An ab4f2210d1
API doc (#872)
* Add the API documentation

* Apply fixes from StyleCI (#871)
2018-12-09 22:24:43 +01:00

46 lines
1.5 KiB
PHP

<?php
namespace App\Providers;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Database\DatabaseManager;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\SQLiteConnection;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Factory as Validator;
use Laravel\Tinker\TinkerServiceProvider;
use Mpociot\ApiDoc\ApiDocGeneratorServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(Builder $schema, DatabaseManager $db, Validator $validator): void
{
// 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', static function ($attribute, $value): bool {
return is_dir($value) && is_readable($value);
});
}
/**
* Register any application services.
*/
public function register(): void
{
if (!$this->app->environment('production')) {
$this->app->register(TinkerServiceProvider::class);
$this->app->register(IdeHelperServiceProvider::class);
$this->app->register(ApiDocGeneratorServiceProvider::class);
}
}
}