mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
088ea287c5
* feat: initial commit for feature management * style: fix StyleCI findings * fix(api): prohibit features of nonnull scope from API & fix(admin): wrong translate key * style: fix Static Analysis error
45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Laravel\Pennant\Middleware\EnsureFeaturesAreActive;
|
|
|
|
/**
|
|
* Class AppServiceProvider.
|
|
*/
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
Model::preventLazyLoading();
|
|
|
|
Model::handleLazyLoadingViolationUsing(function (Model $model, string $relation) {
|
|
$class = get_class($model);
|
|
|
|
Log::error("Attempted to lazy load '$relation' on model '$class'");
|
|
});
|
|
|
|
Model::preventsAccessingMissingAttributes();
|
|
|
|
Model::handleMissingAttributeViolationUsing(function (Model $model, string $key) {
|
|
$class = get_class($model);
|
|
|
|
Log::error("Attribute '$key' does not exist or was not retrieved for model '$class'");
|
|
});
|
|
|
|
EnsureFeaturesAreActive::whenInactive(fn (Request $request, array $features) => new Response(status: 403));
|
|
}
|
|
}
|