ldc-le-gaulois-pro/database/factories/NewsFactory.php

62 lines
2 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\News;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
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()
{
$title = $this->faker->unique()->words(rand(2, 4), true);
if ($this->faker->boolean(50)) {
$picture2Title = $this->faker->words(5, true);
$picture2Alt = $this->faker->words(8, true);
$content2 = $this->faker->words(25, true);
} else {
$picture2Title = null;
$picture2Alt = null;
$content2 = null;
}
if ($this->faker->boolean(50)) {
$eventStart = $this->faker->dateTimeBetween('-30 days', 'now');
$eventEnd = $this->faker->dateTimeBetween('now', '30 days');
$eventText = $this->faker->words(10, true);
} else {
$eventStart = null;
$eventEnd = null;
$eventText = null;
}
return [
'title' => $title,
'slug' => Str::slug($title),
'subtitle' => $this->faker->unique()->words(rand(8, 10), true),
'seo_title' => $this->faker->words(8, true),
'seo_description' => $this->faker->words(25, true),
'picture_title' => $this->faker->words(5, true),
'picture_alt' => $this->faker->words(8, true),
'picture2_title' => $picture2Title,
'picture2_alt' => $picture2Alt,
'content' => $this->faker->words(25, true),
'content2' => $content2,
'event_start' => $eventStart,
'event_end' => $eventEnd,
'event_text' => $eventText,
'status' => $this->faker->boolean(75)
];
}
}