WuYongJie 9595267ee7
Some checks failed
Tests / PHP 8.1 (push) Has been cancelled
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
chore: 导入 Akaunting 初始源码与团队协作规则
2026-07-20 18:20:25 +08:00

56 lines
1.4 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider as Provider;
use Laravel\Sanctum\Sanctum;
class App extends Provider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
if (config('app.installed') && config('app.debug')) {
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}
if (! env_is_production()) {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
Sanctum::ignoreMigrations();
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Laravel db fix
Schema::defaultStringLength(191);
Paginator::useBootstrap();
Model::preventLazyLoading(config('app.eager_load'));
Model::handleLazyLoadingViolationUsing(function ($model, $relation) {
if (config('logging.default') == 'sentry') {
\Sentry\Laravel\Integration::lazyLoadingViolationReporter();
} else {
$class = get_class($model);
report("Attempted to lazy load [{$relation}] on model [{$class}].");
}
});
}
}