Files
online.tbbank.gov.tm-larave…/nova/src/NovaApplicationServiceProvider.php
2024-09-01 18:54:23 +05:00

123 lines
2.5 KiB
PHP

<?php
namespace Laravel\Nova;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Laravel\Nova\Events\ServingNova;
use Laravel\Nova\Exceptions\NovaExceptionHandler;
class NovaApplicationServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->gate();
$this->routes();
Nova::serving(function (ServingNova $event) {
$this->authorization();
$this->registerExceptionHandler();
$this->resources();
Nova::dashboards($this->dashboards());
Nova::tools($this->tools());
});
}
/**
* Register the Nova routes.
*
* @return void
*/
protected function routes()
{
Nova::routes()
->withAuthenticationRoutes()
->withPasswordResetRoutes();
}
/**
* Configure the Nova authorization services.
*
* @return void
*/
protected function authorization()
{
Nova::auth(function ($request) {
return app()->environment('local') ||
Gate::check('viewNova', [Nova::user($request)]);
});
}
/**
* Register the Nova gate.
*
* This gate determines who can access Nova in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewNova', function ($user) {
return in_array($user->email, [
//
]);
});
}
/**
* Get the cards that should be displayed on the Nova dashboard.
*
* @return array
*/
protected function dashboards()
{
return [];
}
/**
* Get the tools that should be listed in the Nova sidebar.
*
* @return array
*/
public function tools()
{
return [];
}
/**
* Register Nova's custom exception handler.
*
* @return void
*/
protected function registerExceptionHandler()
{
app()->bind(ExceptionHandler::class, NovaExceptionHandler::class);
}
/**
* Register the application's Nova resources.
*
* @return void
*/
protected function resources()
{
Nova::resourcesIn(app_path('Nova'));
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}