search([])->map(function (NamiMemberEntry $member) use ($api) { return new CompleteMemberToRedisJob($api, $member->groupId, $member->id); })->toArray(); $batch = Bus::batch($jobs) ->finally(function (Batch $batch) { foreach (Redis::lrange('members', 0, -1) as $data) { try { $data = json_decode($data, true); $localMember = InsertMemberAction::run(NamiMember::from($data['member'])); InsertMembershipsAction::run( $localMember, collect($data['memberships'])->map(fn ($membership) => NamiMembershipEntry::from($membership)), ); InsertCoursesAction::run( $localMember, collect($data['courses'])->map(fn ($course) => NamiCourse::from($course)), ); } catch (Skippable $e) { continue; } } }) ->dispatch(); } public function restore(): void { DB::table('payments')->delete(); DB::table('course_members')->delete(); DB::table('memberships')->delete(); DB::table('members')->delete(); } public function asCommand(Command $command): int { $this->handle(app(NamiSettings::class)->login()); return 0; } }