-menghapus key closed_date di factory -salah menulis relasi di model -antisipasi error ketika image null atau array kosong di index -memindahkan posisi toast menjadi di atas redirect
54 lines
1.4 KiB
PHP
54 lines
1.4 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}'),
|
|
'opened_date' => $this->faker->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,
|
|
];
|
|
});
|
|
}
|
|
}
|