Skip to content

Commit

Permalink
Added model safety
Browse files Browse the repository at this point in the history
  • Loading branch information
lokmanm committed Aug 20, 2023
1 parent b155d84 commit 99d0c28
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Console/InstallsReactorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ protected function installInertiaReact()
$this->installMiddlewareAfter('SubstituteBindings::class', '\App\Http\Middleware\HandleInertiaRequests::class');
$this->installMiddlewareAfter('\App\Http\Middleware\HandleInertiaRequests::class', '\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class');

// Providers...
copy(__DIR__.'/../../stubs/inertia-react/app/Providers/AppServiceProvider.php', app_path('Providers/AppServiceProvider.php'));

copy(__DIR__.'/../../stubs/inertia-react/app/Http/Middleware/HandleInertiaRequests.php', app_path('Http/Middleware/HandleInertiaRequests.php'));

// Views...
Expand Down
27 changes: 27 additions & 0 deletions stubs/inertia-react/app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Model;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
Model::preventLazyLoading(!$this->app->isProduction());
Model::preventAccessingMissingAttributes();
Model::preventSilentlyDiscardingAttributes();
}
}

0 comments on commit 99d0c28

Please sign in to comment.