belongsTo(User::class); } public static function deleteLogsFromDB(): string { $cutoff = Date::now('UTC')->subMonths(3)->toDateTimeString(); $count = count(self::query()->where('created_at', '<', $cutoff)->latest() ->get()); if ($count > 0) { self::query()->where('created_at', '<', $cutoff)->delete(); return "$count old log(s) deleted from the database."; } return 'No logs older than 3 months found.'; } }