setIncludeSample((bool) $this->option('sample')); } // --count 옵션 전파 $counts = $this->parseCountOptions(); if (! empty($counts) && method_exists($seeder, 'setSeederCounts')) { $seeder->setSeederCounts($counts); } return $seeder; } /** * --count 옵션을 파싱하여 연관 배열로 반환합니다. * * 입력: ['products=1000', 'orders=500'] * 출력: ['products' => 1000, 'orders' => 500] * * @return array */ public function parseCountOptions(): array { $countOptions = $this->option('count'); $counts = []; foreach ($countOptions as $option) { if (str_contains($option, '=')) { [$key, $value] = explode('=', $option, 2); $key = trim($key); if ($key !== '') { $counts[$key] = (int) trim($value); } } } return $counts; } /** * 콘솔 커맨드 옵션을 정의합니다. * * 부모 옵션에 --count 옵션을 추가합니다. * * @return array */ protected function getOptions() { return array_merge(parent::getOptions(), [ ['count', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, '시더에 전달할 카운트 옵션 (형식: key=value, 예: --count=products=1000)', []], ['sample', null, InputOption::VALUE_NONE, '샘플 데이터 시더도 함께 실행'], ]); } }