Prevent updating Eloquent Model

September 21, 2019

by Yunus Shaikh

wanted To prevent updating the eloquent model ? Below snippet will prevent updating eloquent model.


    class User extends Eloquent
{
  protected static function boot()
  {
    parent::boot();
    static::updating(function($model)
    {
      return false;
    });
  }
}
This code will prevent updating user.