auth()?->user()?->id, 'loggable_type' => self::class, 'loggable_id' => $this->id, 'action' => LogAction::REQUEST, 'content' => $this->quote, 'ip' => request()->ip(), ]); } protected $fillable = [ 'user_id', 'quote', ]; public function logs(): MorphOne { return $this->morphOne(Log::class, 'loggable'); } public static function boot(): void { parent::boot(); self::created(function (Quote $model) { Log::create([ 'user_id' => auth()?->user()?->id, 'loggable_type' => self::class, 'loggable_id' => $model->id, 'action' => LogAction::CREATE, 'content' => $model->quote, 'ip' => request()->ip(), ]); }); self::deleted(function (Quote $model) { Log::create([ 'user_id' => auth()?->user()?->id, 'loggable_type' => self::class, 'loggable_id' => $model->id, 'action' => LogAction::DELETE, 'content' => $model->quote, 'ip' => request()->ip(), ]); }); } }