siteId = $siteId; } public function collection(Collection $collections) { $list = []; $delList = []; foreach ($collections as $key => $collection) { if ($key < 1) { continue; } if (trim($collection[1]) == 1) { $delList[] = trim($collection[0]); } else { $update = [ 'site_id' => $this->siteId, 'label' => trim($collection[0]), ]; $list[] = $update; } } if (!empty($list)) { DB::table('social_label')->insert($list); } if (!empty($delList)) { DB::table('social_label') ->where('site_id', $this->siteId) ->whereIn('label', $delList) ->delete(); } } }