isDirty('updated_by_user')) { $model->updated_by_user = Auth::guard('web')->user()->id; } }); // updating updated_by when model is updated static::updating(function ($model) { if (!$model->isDirty('updated_by_user')) { $model->updated_by_user = Auth::guard('web')->user()->id; } }); } protected $table = 'taggable_contexts'; protected $guarded = []; public function tags() { return $this->belongsToMany(Tag::class, 'taggable_locale_context', 'context_id', 'tag_id'); } public function category() { return $this->belongsTo(Category::class); } }