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;
|
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
|
|
|
|
2020-10-14 17:07:59 +03:00
|
|
|
if (config('app.env') !== 'production') {
|
|
|
|
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
|
2019-12-13 19:27:14 +03:00
|
|
|
}
|
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) {
|
|
|
|
$class = get_class($model);
|
|
|
|
|
2021-06-08 23:33:17 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|