42 lines
962 B
PHP
42 lines
962 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/** @noinspection PhpIllegalPsrClassPathInspection */
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Contracts\Factory;
|
|
use App\Enums\FareType;
|
|
use App\Models\Fare;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<Fare>
|
|
*/
|
|
class FareFactory extends Factory
|
|
{
|
|
/**
|
|
* The name of the factory's corresponding model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $model = Fare::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'code' => fake()->unique()->text(50),
|
|
'name' => fake()->text(50),
|
|
'price' => fake()->randomFloat(2, 100, 1000),
|
|
'cost' => fn (array $fare): float => round($fare['price'] / 2),
|
|
'capacity' => fake()->randomFloat(0, 20, 500),
|
|
'type' => FareType::PASSENGER,
|
|
];
|
|
}
|
|
}
|