| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace Database\Factories;
- use App\Models\Order;
- use App\Models\Reclamation;
- use App\Models\User;
- use Illuminate\Database\Eloquent\Factories\Factory;
- /**
- * @extends Factory<Reclamation>
- */
- class ReclamationFactory extends Factory
- {
- protected $model = Reclamation::class;
- public function definition(): array
- {
- return [
- 'order_id' => Order::factory(),
- 'user_id' => User::factory(),
- 'status_id' => Reclamation::STATUS_NEW,
- 'reason' => fake()->sentence(),
- 'guarantee' => fake()->boolean(),
- 'whats_done' => fake()->optional()->sentence(),
- 'create_date' => fake()->dateTimeBetween('-1 month', 'now')->format('Y-m-d'),
- 'finish_date' => null,
- 'start_work_date' => null,
- 'work_days' => null,
- 'brigadier_id' => null,
- 'comment' => fake()->optional()->sentence(),
- ];
- }
- public function withStatus(int $status): static
- {
- return $this->state(fn (array $attributes) => [
- 'status_id' => $status,
- ]);
- }
- public function inWork(): static
- {
- return $this->state(fn (array $attributes) => [
- 'status_id' => Reclamation::STATUS_IN_WORK,
- 'start_work_date' => now()->format('Y-m-d'),
- ]);
- }
- public function done(): static
- {
- return $this->state(fn (array $attributes) => [
- 'status_id' => Reclamation::STATUS_DONE,
- 'finish_date' => now()->format('Y-m-d'),
- ]);
- }
- public function forOrder(Order $order): static
- {
- return $this->state(fn (array $attributes) => [
- 'order_id' => $order->id,
- ]);
- }
- }
|