42 lines
989 B
PHP
42 lines
989 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\News;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
use Illuminate\Support\Str;
|
|
|
|
/**
|
|
* @extends Factory<\App\Models\News>
|
|
*/
|
|
final class NewsFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = News::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$title = fake()->word;
|
|
$locales = \collect(\config('app.locales'))->shuffle();
|
|
$locales->shift(\rand(0, 1));
|
|
return [
|
|
'seo_title' => fake()->word,
|
|
'seo_description' => fake()->text(150),
|
|
'title' => $title,
|
|
'slug' => Str::slug($title),
|
|
'subtitle' => fake()->word,
|
|
'content' => fake()->text(150),
|
|
'status' => fake()->boolean(),
|
|
'locales' => $locales
|
|
];
|
|
}
|
|
}
|