29 lines
599 B
PHP
29 lines
599 B
PHP
<?php
|
|
|
|
namespace Zoomyboy\Osm;
|
|
|
|
trait HasGeolocation
|
|
{
|
|
public static bool $geolocationEnabled = true;
|
|
|
|
public static function bootHasGeolocation(): void
|
|
{
|
|
static::saved(function (Geolocatable $model) {
|
|
if (!static::$geolocationEnabled) {
|
|
return;
|
|
}
|
|
dispatch(new FillCoordsJob($model));
|
|
});
|
|
}
|
|
|
|
public static function disableGeolocation(): void
|
|
{
|
|
static::$geolocationEnabled = false;
|
|
}
|
|
|
|
public static function enableGeolocation(): void
|
|
{
|
|
static::$geolocationEnabled = true;
|
|
}
|
|
}
|