Files
2022-11-09 16:33:43 +01:00

41 lines
938 B
PHP

<?php
namespace Database\Factories;
use App\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
/** @extends Factory<Location> */
class LocationFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'location' => $this->faker->randomElement([
$this->faker->sentence($this->faker->numberBetween(1, 10)),
str_replace("\n", ' ', $this->faker->address()),
]),
];
}
/**
* Indicate add lat,lng
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
public function withCoordinates()
{
return $this->state(function (array $attributes) {
return [
'lat' => $this->faker->latitude(),
'lng' => $this->faker->longitude(),
];
});
}
}