librenms-librenms/database/factories/LocationFactory.php
SourceDoctor 75a0a5e374 Use DNS Location Record for Location (#12409)
* Use DNS Location Record for Location

* .

* .

* .

* grammar fix

* dns class

* code changes

* composer update

* add missing composer.lock update

* reposition Location record parsing

* composer update

* default yes ; change lookup order

* merge master

* .

* move Location Record Parser to Model Level

* .

* fix location record code

* Location precedence with tests
Setting from UI disables all lookups

* update composer.lock and mix-manifest.json

* Style fixes

Co-authored-by: Tony Murray <murraytony@gmail.com>
2021-02-22 11:17:40 +01:00

47 lines
1.0 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
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,
];
});
}
}