ldc-doux/database/factories/PostFactory.php
2022-01-23 15:25:17 +01:00

39 lines
1.1 KiB
PHP

<?php
namespace Database\Factories;
use App\Lib\Utils;
use App\Models\Post;
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()
{
$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());
return [
'title' => $this->faker->text(5),
'text' => $this->faker->paragraph(10, false),
'picture_home' => $imghomepath,
'alt_text_picture_home' => $this->faker->sentence(10),
'picture_news' => $imgnewspath,
'alt_text_picture_news' => $this->faker->sentence(10),
'date_start' => Carbon::now(),
'date_end' => Carbon::now()->addDays(2),
'on_top' => true
];
}
}