created_by = Auth::id(); } }); static::updating(function ($model) { if (Auth::check()) { $model->updated_by = Auth::id(); } }); static::deleting(function ($model) { if (Auth::check()) { $model->deleted_by = Auth::id(); // for delete, need to update the model manually $model->save(); } }); } public function creator() { return $this->belongsTo(User::class, 'created_by'); } public function editor() { return $this->belongsTo(User::class, 'updated_by'); } public function deleter() { return $this->belongsTo(User::class, 'deleted_by'); } }