Unguard Models

Submitted by berto309 - 3 years ago

You can unguard all your Models instead of setting the protected guarded variable to an empty array in each App\Models\YourModel class using Model::unguard() in the boot method of AppServiceProvider class.

<?php 
namespace App\Providers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;


class AppServiceProvider extends ServiceProvider
{
 /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(){
     
        Model::unguard();
    }


}