librenms-librenms/database/factories/LocationFactory.php
Jellyfrog e873768845 Bump larastan (#13071)
* Bump larastan

* Use php7.4 for lint test
2021-07-26 09:00:34 -05:00

48 lines
1.0 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
/** @extends Factory<Location> */
class LocationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Location::class;
/**
* 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,
];
});
}
}