activityLogs()->create($data); } /** * Define a polymorphic one-to-many relationship for activity logs. * * @return \Illuminate\Database\Eloquent\Relations\MorphMany */ public function activityLogs(): MorphMany { return $this->morphMany(ActivityLog::class, 'loggable')->latest(); } // $estimate->customer->createLog([ // 'title' => 'Estimate Created', // 'data' => "Estimate {$estimate->estimate_code} was created by " . auth()->user()->name . ".", // ]); }