ldc-doux/database/factories/PostFactory.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2021-12-17 17:27:25 +01:00
<?php
namespace Database\Factories;
2022-01-23 15:25:17 +01:00
use App\Lib\Utils;
use App\Models\Post;
2021-12-17 17:27:25 +01:00
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
use SplFileInfo;
class PostFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
2022-01-23 15:25:17 +01:00
$upload = new SplFileInfo(resource_path('assets/images/burger-fond.jpg'));
$picture = new Post();
$imghomepath = Utils::storeImage($upload, $picture->getTable());
$upload = new SplFileInfo(resource_path('assets/images/burger.jpg'));
$imgnewspath = Utils::storeImage($upload, $picture->getTable());
2021-12-17 17:27:25 +01:00
return [
'title' => $this->faker->text(5),
'text' => $this->faker->paragraph(10, false),
2022-01-23 15:25:17 +01:00
'picture_home' => $imghomepath,
2021-12-20 14:02:37 +01:00
'alt_text_picture_home' => $this->faker->sentence(10),
2022-01-23 15:25:17 +01:00
'picture_news' => $imgnewspath,
2021-12-20 14:02:37 +01:00
'alt_text_picture_news' => $this->faker->sentence(10),
2021-12-17 17:27:25 +01:00
'date_start' => Carbon::now(),
'date_end' => Carbon::now()->addDays(2),
2021-12-22 17:32:05 +01:00
'on_top' => true
2021-12-17 17:27:25 +01:00
];
}
}