ldc-le-gaulois-pro/database/factories/SlideFactory.php
2026-03-25 10:45:26 +01:00

51 lines
1.7 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Slide;
use Illuminate\Database\Eloquent\Factories\Factory;
class SlideFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Slide::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$button_displayed = $this->faker->boolean(75);
if ($button_displayed) {
$button_text = $this->faker->unique()->words(rand(2, 4), true);
$button_url = $this->faker->url();
$button_targetblank = $this->faker->boolean(25);
} else {
$button_text = null;
$button_url = null;
$button_targetblank = null;
}
$picture_alt = $this->faker->unique()->words(rand(15, 25), true);
$picture_title = $this->faker->unique()->words(rand(2, 4), true);
return [
'title' => $this->faker->unique()->words(rand(2, 4), true),
'content' => $this->faker->unique()->words(rand(15, 25), true),
'button_display' => $button_displayed,
'button_text' => $button_text,
'button_url' => $button_url,
'button_targetblank' => $button_targetblank,
'picture_alt' => $picture_alt,
'picture_title' => $picture_title,
'picture_thumbnail_alt' => $picture_alt,
'picture_thumbnail_title' => $picture_title,
'published' => $this->faker->boolean(),
];
}
}