ldc-startcoq/database/factories/SurveyFactory.php
2023-06-21 10:24:56 +00:00

41 lines
965 B
PHP

<?php
namespace Database\Factories;
use App\Models\Survey;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<\App\Models\Survey>
*/
final class SurveyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Survey::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
$is = fake()->boolean;
return [
'user_id' => fake()->randomElement(User::pluck('id')),
'name' => fake()->word,
'author' => fake()->word,
'comment' => fake()->word,
'date' => fake()->dateTime(),
'documents' => [fake()->word],
'is_distributor' => ($is) ? 1 : 0,
'is_customer' => (!$is) ? 1 : 0,
'deleted_at' => fake()->dateTime(),
];
}
}