where('id', 3) // ->chunkById(500, function($competitions) { // foreach ($competitions as $competition) { // $this->syncTeam($competition->competition_id, ''); // } // }); /** @var AlStatService $alStatService */ $alStatService = app(AlStatService::class); $teams = $alStatService->getZqTeam(); if (!$teams) { return; } foreach ($teams as $item) { $teamId = $item['id']; $team = ZqTeam::where('team_id', $teamId)->first(); if (!$team) { $team = new ZqTeam(); } $team->team_id = $teamId; $team->competition_id = intval(Arr::get($item, 'competitionId')); $team->name = strval(Arr::get($item, 'name')); $team->name_full = strval(Arr::get($item, 'nameFull')); $team->name_en = strval(Arr::get($item, 'nameEn')); $team->name_en_full = strval(Arr::get($item, 'nameEnFull')); $team->team_type = strval(Arr::get($item, 'teamType')); $team->league_id = intval(Arr::get($item, 'leagueId')); $team->country = strval(Arr::get($item, 'country')); $team->save(); } } }