*/ class OrderFactory extends Factory { protected $model = Order::class; public function definition(): array { return [ 'year' => (int) date('Y'), 'name' => fake()->bothify('Заказ-####'), 'user_id' => User::factory(), 'district_id' => District::factory(), 'area_id' => Area::factory(), 'object_address' => fake()->address(), 'object_type_id' => ObjectType::factory(), 'comment' => fake()->optional()->sentence(), 'installation_date' => fake()->optional()->dateTimeBetween('now', '+3 months')?->format('Y-m-d'), 'ready_date' => fake()->optional()->dateTimeBetween('-1 month', 'now')?->format('Y-m-d'), 'brigadier_id' => null, 'order_status_id' => Order::STATUS_NEW, 'tg_group_name' => null, 'tg_group_link' => null, 'ready_to_mount' => 'Нет', 'install_days' => fake()->numberBetween(1, 14), ]; } public function withStatus(int $status): static { return $this->state(fn (array $attributes) => [ 'order_status_id' => $status, ]); } public function readyToMount(): static { return $this->state(fn (array $attributes) => [ 'order_status_id' => Order::STATUS_READY_TO_MOUNT, 'ready_to_mount' => 'Да', ]); } public function inMount(): static { return $this->state(fn (array $attributes) => [ 'order_status_id' => Order::STATUS_IN_MOUNT, ]); } public function handedOver(): static { return $this->state(fn (array $attributes) => [ 'order_status_id' => Order::STATUS_HANDED_OVER, ]); } public function withBrigadier(User $brigadier = null): static { return $this->state(fn (array $attributes) => [ 'brigadier_id' => $brigadier?->id ?? User::factory(), ]); } }