phpvms/app/Providers/AppServiceProvider.php

59 lines
1.8 KiB
PHP
Raw Normal View History

2017-06-09 02:28:26 +08:00
<?php
2017-06-09 02:28:26 +08:00
namespace App\Providers;
use App\Notifications\Channels\Discord\DiscordWebhook;
use App\Services\ModuleService;
use App\Support\ThemeViewFinder;
use App\Support\Utils;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\View;
2017-06-09 02:28:26 +08:00
use Illuminate\Support\ServiceProvider;
2017-06-09 02:28:26 +08:00
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
2017-06-09 02:28:26 +08:00
{
Schema::defaultStringLength(191);
Paginator::useBootstrap();
View::share('moduleSvc', app(ModuleService::class));
Notification::extend('discord_webhook', function ($app) {
return app(DiscordWebhook::class);
});
2017-06-09 02:28:26 +08:00
}
/**
* Register any application services.
*/
public function register(): void
2017-06-09 02:28:26 +08:00
{
$this->app->singleton('view.finder', function ($app) {
return new ThemeViewFinder(
$app['files'],
$app['config']['view.paths'],
null
);
});
// Only load the IDE helper if it's included and enabled
if (config('app.debug') === true) {
2018-08-27 02:51:47 +08:00
/* @noinspection NestedPositiveIfStatementsInspection */
/* @noinspection PhpFullyQualifiedNameUsageInspection */
if (class_exists(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class)) {
/* @noinspection PhpFullyQualifiedNameUsageInspection */
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
if (config('app.debug_toolbar') === true) {
Utils::enableDebugToolbar();
} else {
Utils::disableDebugToolbar();
}
}
2017-06-09 02:28:26 +08:00
}
}