fix : sync issu

This commit is contained in:
SajjadMahmoody
2026-04-19 11:29:57 +03:30
parent d657c48600
commit 95592aa510
6 changed files with 63 additions and 22 deletions
+15 -5
View File
@@ -32,12 +32,22 @@ public static function lastSyncId(): int
return (int) static::where('action', 'synced')->max('id') ?: 0;
}
public static function changesSince(int $since): \Illuminate\Database\Eloquent\Collection
public static function changesSince(?string $since): \Illuminate\Database\Eloquent\Collection
{
return static::where('id', '>', $since)
->whereIn('action', ['created', 'updated', 'deleted'])
->orderBy('id')
->get();
$query = static::whereIn('action', ['created', 'updated', 'deleted'])
->orderBy('datetime')
->orderBy('id');
if ($since !== null && $since !== '') {
$query->where('datetime', '>', $since);
}
return $query->get();
}
protected function serializeDate(\DateTimeInterface $date): string
{
return $date->format('Y-m-d H:i:s');
}
public static function markSynced(string $ip): static