36 lines
753 B
PHP
36 lines
753 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Hub;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<Hub>
|
|
*/
|
|
class HubFactory extends Factory
|
|
{
|
|
protected $model = Hub::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
$name = fake()->city().' '.fake()->randomElement(['Region', 'Hub', 'Gebiet']);
|
|
|
|
return [
|
|
'name' => $name,
|
|
'slug' => Str::slug($name).'-'.fake()->unique()->numberBetween(100, 999),
|
|
'is_active' => true,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Inaktiver Hub.
|
|
*/
|
|
public function inactive(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'is_active' => false,
|
|
]);
|
|
}
|
|
}
|