67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\OutletStatus;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class OutletFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => $this->faker->company(),
|
|
'phone_number' => sprintf(
|
|
'%04d %04d %03d',
|
|
$this->faker->numberBetween(8000, 8999),
|
|
$this->faker->numberBetween(1000, 9999),
|
|
$this->faker->numberBetween(100, 999)
|
|
),
|
|
'address' => $this->faker->address(),
|
|
'landmark' => $this->faker->streetName(),
|
|
'maps_url' => 'https://goo.gl/maps/'.$this->faker->regexify('[A-Za-z0-9]{6,10}'),
|
|
'opening_hours' => collect(['senin', 'selasa', 'rabu', 'kamis', 'jumat', 'sabtu', 'minggu'])
|
|
->mapWithKeys(fn ($day) => [
|
|
$day => [
|
|
'open' => $this->faker->time('H:i'),
|
|
'close' => $this->faker->time('H:i'),
|
|
],
|
|
])
|
|
->toArray(),
|
|
'facilities' => $this->faker->randomElements(
|
|
['WiFi', 'Parking', 'Toilet', 'Musholla', 'Smoking Area'],
|
|
$this->faker->numberBetween(1, 3)
|
|
),
|
|
'opened_date' => $this->faker->date(),
|
|
'closed_date' => $this->faker->optional()->date(),
|
|
];
|
|
}
|
|
|
|
public function operational(): Factory
|
|
{
|
|
return $this->state(function (array $attributes) {
|
|
return [
|
|
'status' => OutletStatus::OPERATIONAL,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function underConstruction(): Factory
|
|
{
|
|
return $this->state(function (array $attributes) {
|
|
return [
|
|
'status' => OutletStatus::UNDER_CONSTRUCTION,
|
|
];
|
|
});
|
|
}
|
|
|
|
public function terminated(): Factory
|
|
{
|
|
return $this->state(function (array $attributes) {
|
|
return [
|
|
'status' => OutletStatus::TERMINATED,
|
|
];
|
|
});
|
|
}
|
|
}
|