ldc-lionor/database/factories/ShopFactory.php
2023-02-24 15:20:58 +00:00

48 lines
1.5 KiB
PHP

<?php
namespace Database\Factories;
use App\Enums\SignsEnum;
use App\Models\Shop;
use Illuminate\Database\Eloquent\Factories\Factory;
class ShopFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Shop::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->unique()->company(),
'signs' => collect(SignsEnum::toArray())->random(),
'address' => $this->faker->randomNumber(3, false) . ', ' .
$this->faker->unique()->words((int)$this->faker->randomFloat(0, 2, 3), true),
'city' => $this->faker->city(),
'postcode' => \str_replace(' ', '', $this->faker->postcode()),
'latitude' => \sprintf(
'%d°%d\'%s"%s',
(int)$this->faker->randomFloat(0, 0, 89),
(int)$this->faker->randomFloat(0, 0, 59),
\number_format($this->faker->randomFloat(1, 0, 59), 1),
$this->faker->boolean() ? 'N' : 'S'
),
'longitude' => \sprintf(
'%d°%d\'%s"%s',
(int)$this->faker->randomFloat(0, 0, 179),
(int)$this->faker->randomFloat(0, 0, 59),
\number_format($this->faker->randomFloat(1, 0, 59), 1),
$this->faker->boolean() ? 'E' : 'W'
)
];
}
}