Illuminate\Database\Eloquent\Model::unguarded PHP Method

unguarded() public static method

Run the given callable while being unguarded.
public static unguarded ( callable $callback ) : mixed
$callback callable
return mixed
    public static function unguarded(callable $callback)
    {
        if (static::$unguarded) {
            return $callback();
        }
        static::unguard();
        try {
            return $callback();
        } finally {
            static::reguard();
        }
    }

Usage Example

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->resolver->setDefaultConnection($this->getDatabase());
     Model::unguarded(function () {
         $this->getSeeder()->run();
     });
 }
All Usage Examples Of Illuminate\Database\Eloquent\Model::unguarded
Model