40 lines
940 B
PHP
40 lines
940 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Export;
|
|
use App\Models\Request;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class RequestFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = Request::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function definition()
|
|
{
|
|
return [
|
|
'name' => $this->faker->name(),
|
|
'phone' => $this->faker->phoneNumber(),
|
|
'email' => $this->faker->safeEmail(),
|
|
'items' => Export::inRandomOrder()
|
|
->limit(mt_rand(3, 10))
|
|
->get()
|
|
->map(function ($item) {
|
|
$item->count = mt_rand(10, 100);
|
|
return $item;
|
|
}),
|
|
'created_at' => $this->faker->dateTimeThisYear(),
|
|
];
|
|
}
|
|
}
|