| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace Database\Factories;
- use App\Models\Import;
- use App\Models\User;
- use Illuminate\Database\Eloquent\Factories\Factory;
- /**
- * @extends Factory<Import>
- */
- class ImportFactory extends Factory
- {
- protected $model = Import::class;
- public function definition(): array
- {
- return [
- 'type' => fake()->randomElement(['orders', 'mafs', 'reclamations', 'catalog']),
- 'year' => (int) date('Y'),
- 'filename' => fake()->uuid() . '.xlsx',
- 'status' => Import::STATUS_PENDING,
- 'result' => '',
- 'user_id' => User::factory(),
- 'file_path' => null,
- 'original_filename' => fake()->word() . '.xlsx',
- ];
- }
- public function pending(): static
- {
- return $this->state(fn (array $attributes) => [
- 'status' => Import::STATUS_PENDING,
- ]);
- }
- public function completed(): static
- {
- return $this->state(fn (array $attributes) => [
- 'status' => Import::STATUS_COMPLETED,
- ]);
- }
- public function failed(): static
- {
- return $this->state(fn (array $attributes) => [
- 'status' => Import::STATUS_FAILED,
- ]);
- }
- public function orders(): static
- {
- return $this->state(fn (array $attributes) => [
- 'type' => 'orders',
- ]);
- }
- public function mafs(): static
- {
- return $this->state(fn (array $attributes) => [
- 'type' => 'mafs',
- ]);
- }
- public function reclamations(): static
- {
- return $this->state(fn (array $attributes) => [
- 'type' => 'reclamations',
- ]);
- }
- }
|