ldc-doux/database/factories/SlideFactory.php
2022-08-11 12:34:27 +02:00

44 lines
1.1 KiB
PHP

<?php
namespace Database\Factories;
use App\Lib\Utils;
use App\Models\Slide;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
use SplFileInfo;
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()
{
$upload = new SplFileInfo(resource_path('assets/images/image-sample.jpg'));
$slide = new Slide();
$imgpath = Utils::storeImage($upload, $slide->getTable());
return [
'title' => $this->faker->unique()->word(),
'text' => $this->faker->realText(25),
'link_label' => $this->faker->text(128),
'link' => route('wasup'),
'link_new_tab' => rand(0, 1),
'date_start' => Carbon::now(),
'date_end' => Carbon::now()->addDays(2),
'picture' => $imgpath,
'alt_text_picture' => $this->faker->sentence(10),
];
}
}