56 lines
1.4 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Providers;
2021-06-07 16:09:47 +03:00
use Illuminate\Database\Eloquent\Model;
2020-10-14 17:07:59 +03:00
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
2019-11-16 10:21:14 +03:00
use Illuminate\Support\ServiceProvider as Provider;
2022-06-01 10:15:55 +03:00
use Laravel\Sanctum\Sanctum;
2017-09-14 22:21:00 +03:00
2019-11-16 10:21:14 +03:00
class App extends Provider
2017-09-14 22:21:00 +03:00
{
/**
2020-10-14 17:07:59 +03:00
* Register any application services.
2017-09-14 22:21:00 +03:00
*
* @return void
*/
2020-10-14 17:07:59 +03:00
public function register()
2017-09-14 22:21:00 +03:00
{
2020-10-14 17:07:59 +03:00
if (config('app.installed') && config('app.debug')) {
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}
2019-11-16 10:21:14 +03:00
2022-06-13 10:01:46 +03:00
if (! env_is_production()) {
2020-10-14 17:07:59 +03:00
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
2019-12-13 19:27:14 +03:00
}
2022-06-01 10:15:55 +03:00
Sanctum::ignoreMigrations();
2017-09-14 22:21:00 +03:00
}
/**
2020-10-14 17:07:59 +03:00
* Bootstrap any application services.
2017-09-14 22:21:00 +03:00
*
* @return void
*/
2020-10-14 17:07:59 +03:00
public function boot()
2017-09-14 22:21:00 +03:00
{
2020-10-14 17:07:59 +03:00
// Laravel db fix
Schema::defaultStringLength(191);
2017-09-14 22:21:00 +03:00
2020-10-14 17:07:59 +03:00
Paginator::useBootstrap();
2021-06-07 16:09:47 +03:00
2021-08-10 23:10:26 +03:00
Model::preventLazyLoading(config('app.eager_load'));
2021-06-07 16:09:47 +03:00
Model::handleLazyLoadingViolationUsing(function ($model, $relation) {
2023-05-31 10:01:17 +03:00
if (config('logging.default') == 'sentry') {
\Sentry\Laravel\Integration::lazyLoadingViolationReporter();
} else {
$class = get_class($model);
report("Attempted to lazy load [{$relation}] on model [{$class}].");
}
2021-06-07 16:09:47 +03:00
});
2017-09-14 22:21:00 +03:00
}
}