X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FSyncSpeedGaming.php;h=6d0fa1faa777801f213af2f38abfb8c62ec33047;hb=e7eb3495728ca9c2883d7cf07b363b48a95231fe;hp=eaaa4fa48e7ccb5989d0c4ca29218ed3c80857c5;hpb=343b423a42670ec21cdb95025020264346ad62fb;p=alttp.git diff --git a/app/Console/Commands/SyncSpeedGaming.php b/app/Console/Commands/SyncSpeedGaming.php index eaaa4fa..6d0fa1f 100644 --- a/app/Console/Commands/SyncSpeedGaming.php +++ b/app/Console/Commands/SyncSpeedGaming.php @@ -176,10 +176,13 @@ class SyncSpeedGaming extends Command { foreach ($sgEntry['channels'] as $sgChannel) { $ext_ids[] = 'sg:'.$sgChannel['id']; } - $episode->channels() - ->where('ext_id', 'LIKE', 'sg:%') - ->whereNotIn('ext_id', $ext_ids) - ->detach(); + $channels = $episode->channels() + ->where('ext_id', 'LIKE', 'sg:%') + ->whereNotIn('ext_id', $ext_ids) + ->get(); + if (!$channels->isEmpty()) { + $episode->channels()->detach($channels->pluck('id')); + } } private function syncChannel(Episode $episode, $sgChannel) {