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

51 lines
1.5 KiB
PHP
Raw Normal View History

2022-12-01 12:25:55 +01:00
<?php
namespace Database\Factories;
use App\Models\Slide;
2022-12-01 12:25:55 +01:00
use Illuminate\Database\Eloquent\Factories\Factory;
class SlideFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Slide::class;
2022-12-01 12:25:55 +01:00
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$button_displayed = $this->faker->boolean(75);
if ($button_displayed) {
2022-12-08 13:10:13 +01:00
$button_text = $this->faker->unique()->words(rand(2, 4), true);
$button_url = $this->faker->url();
$button_targetblank = $this->faker->boolean(25);
2022-12-01 12:25:55 +01:00
} else {
2022-12-08 13:10:13 +01:00
$button_text = null;
$button_url = null;
$button_targetblank = null;
2022-12-01 12:25:55 +01:00
}
$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,
2022-12-08 13:10:13 +01:00
'button_targetblank' => $button_targetblank,
2022-12-01 12:25:55 +01:00
'picture_alt' => $picture_alt,
'picture_title' => $picture_title,
'picture_thumbnail_alt' => $picture_alt,
2022-12-08 13:10:13 +01:00
'picture_thumbnail_title' => $picture_title
2022-12-01 12:25:55 +01:00
];
}
}