isDirty('createdBy')) { $model->createdBy = auth()->user() ? auth()->user()->id : null; } if (!$model->isDirty('updatedBy')) { $model->updatedBy = auth()->user() ? auth()->user()->id : null; } if ($model->isDirty('createdOn') && !$model->isDirty('createdOn')) { $model->createdOn = now(); } // if (!$model->isDirty('status')) { // $model->status = 11; // } }); // updating updated_by when model is updated static::updating(function ($model) { if (!$model->isDirty('updatedBy')) { $model->updatedBy = auth()->user() ? auth()->user()->id : 1; } }); } }