'array', 'new_values' => 'array', 'created_at' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Helper statis untuk merekam log aktivitas Super Admin secara otomatis. */ public static function record( string $actionType, string $module, string $description, ?string $targetType = null, ?int $targetId = null, ?string $targetName = null, ?array $oldValues = null, ?array $newValues = null ): self { $actor = Auth::user(); return self::create([ 'user_id' => $actor?->id, 'user_name' => $actor?->name ?? 'Super Admin', 'user_username' => $actor?->username ?? 'superadmin', 'action_type' => $actionType, 'module' => $module, 'target_type' => $targetType, 'target_id' => $targetId, 'target_name' => $targetName, 'description' => $description, 'old_values' => $oldValues, 'new_values' => $newValues, 'ip_address' => Request::ip(), 'user_agent' => Request::userAgent(), ]); } }