*/ class ProductionOrderFactory extends Factory { protected $model = ProductionOrder::class; public function definition(): array { $paymentDate = CarbonImmutable::instance(fake()->dateTimeBetween('-3 months', '+1 month')); $supplyDays = fake()->numberBetween(5, 60); return [ 'external_id' => null, 'source' => ProductionOrderSource::Manual, 'order_number' => fake()->unique()->numerify('####.##'), 'order_year' => (int) $paymentDate->format('Y'), 'customer_name' => fake()->company(), 'object_address' => fake()->address(), 'invoice_number' => fake()->numerify('СЧ-######'), 'invoice_date' => $paymentDate->subDays(2), 'contract_number' => fake()->optional()->numerify('Д-######'), 'contract_date' => fake()->optional()->passthrough($paymentDate->subDays(10)), 'payment_date' => $paymentDate, 'supply_working_days' => $supplyDays, 'contract_shipment_date' => $paymentDate->addWeekdays($supplyDays), 'application_shipment_date' => null, 'status' => ProductionOrderStatus::Placed, 'execution_type' => fake()->randomElement(ProductionOrderExecutionType::cases()), 'manager_id' => User::factory()->manager(), 'note' => fake()->optional()->sentence(), 'created_by' => null, 'updated_by' => null, ]; } }