search($settings->search_params)->map(fn ($member) => $member->id)->toArray(); foreach (Member::remote()->whereNotIn('nami_id', $memberIds)->get() as $member) { if ($member->efz !== null || $member->ps_at !== null || $member->more_ps_at !== null) { Log::error('Mitglied ' . $member->id . ' wird nicht gelöscht werden.'); continue; } $member->delete(); } $jobs = $api->search($settings->search_params)->map(function (NamiMemberEntry $member) use ($api) { return FullMemberAction::makeJob($api, $member->groupId, $member->id, 'members'); })->toArray(); Bus::batch($jobs) ->finally(function () { /** @var array */ $members = array_map(fn ($member) => FullMember::from(json_decode($member, true)), Redis::lrange('members', 0, -1)); foreach ($members as $data) { InsertFullMemberAction::dispatch($data); } }) ->onQueue('long') ->allowFailures() ->dispatch(); } public function asCommand(): int { $this->handle(app(NamiSettings::class)->login()); return 0; } }