104 lines
2.7 KiB
PHP
104 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\EventStatus;
|
|
use App\Enums\EventVisibility;
|
|
use App\Models\Customer;
|
|
use App\Models\Event;
|
|
use App\Models\Location;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Event>
|
|
*/
|
|
final class EventFactory extends Factory
|
|
{
|
|
protected $model = Event::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$startTime = fake()->time('H:i');
|
|
$endTime = fake()->optional()->time('H:i');
|
|
|
|
return [
|
|
'title' => fake()->sentence(3),
|
|
'description' => fake()->optional()->paragraph(),
|
|
'event_date' => fake()->dateTimeBetween('+1 week', '+6 months'),
|
|
'start_time' => $startTime,
|
|
'end_time' => $endTime,
|
|
'fee' => fake()->optional()->randomFloat(2, 100, 5000),
|
|
'currency' => 'EUR',
|
|
'status' => fake()->randomElement(EventStatus::cases()),
|
|
'visibility' => EventVisibility::Members,
|
|
'notes' => fake()->optional()->paragraph(),
|
|
'created_by' => User::factory(),
|
|
];
|
|
}
|
|
|
|
public function draft(): static
|
|
{
|
|
return $this->state(fn () => ['status' => EventStatus::Draft]);
|
|
}
|
|
|
|
public function pending(): static
|
|
{
|
|
return $this->state(fn () => ['status' => EventStatus::Pending]);
|
|
}
|
|
|
|
public function confirmed(): static
|
|
{
|
|
return $this->state(fn () => ['status' => EventStatus::Confirmed]);
|
|
}
|
|
|
|
public function completed(): static
|
|
{
|
|
return $this->state(fn () => ['status' => EventStatus::Completed]);
|
|
}
|
|
|
|
public function cancelled(): static
|
|
{
|
|
return $this->state(fn () => ['status' => EventStatus::Cancelled]);
|
|
}
|
|
|
|
public function withLocation(): static
|
|
{
|
|
return $this->state(fn () => ['location_id' => Location::factory()]);
|
|
}
|
|
|
|
public function withCustomer(): static
|
|
{
|
|
return $this->state(fn () => ['customer_id' => Customer::factory()]);
|
|
}
|
|
|
|
public function upcoming(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'event_date' => fake()->dateTimeBetween('+1 day', '+1 month'),
|
|
'status' => EventStatus::Confirmed,
|
|
]);
|
|
}
|
|
|
|
public function past(): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'event_date' => fake()->dateTimeBetween('-6 months', '-1 day'),
|
|
'status' => EventStatus::Completed,
|
|
]);
|
|
}
|
|
|
|
public function privateEvent(): static
|
|
{
|
|
return $this->state(fn () => ['visibility' => EventVisibility::Private]);
|
|
}
|
|
|
|
public function publicEvent(): static
|
|
{
|
|
return $this->state(fn () => ['visibility' => EventVisibility::Public]);
|
|
}
|
|
}
|
|
|