option('dry-run'); $users = User::query() ->where('active', 1) ->where('admin', 0) ->whereDoesntHave('shop') ->with('account') ->orderBy('id') ->get(); $rows = []; foreach ($users as $user) { $name = $dryRun ? UserShopService::generateDefaultName($user, array_column($rows, 2)) : UserShopService::ensureForUser($user)->name; $rows[] = [$user->id, $user->email, $name]; } $this->table(['User', 'E-Mail', 'Shop'], $rows); $this->info(($dryRun ? '[DRY-RUN] ' : '').count($rows).' Berater ohne Shop'.($dryRun ? ' gefunden.' : ' mit Standard-Shop versorgt.')); if (! $dryRun && count($rows)) { \Log::channel('cleanup')->info('COMMAND [user:ensure-shops] created '.count($rows).' shops.', [ 'user_ids' => array_column($rows, 0), ]); } return self::SUCCESS; } }