fix : sync issu
This commit is contained in:
+15
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user