pai-sklep/database/factories/ImageFactory.php

34 lines
699 B
PHP

<?php
namespace Database\Factories;
use App\Models\Image;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Http\File;
use Illuminate\Support\Facades\Storage;
use illuminate\support\str;
class ImageFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Image::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$imageFile = new File($this->faker->image());
return [
'uuid' => (string) Str::uuid(),
'path' => Storage::putFile("uploads", $imageFile),
];
}
}