2023-05-16 14:29:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zoomyboy\Osm;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
class FillCoordsJob implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Dispatchable;
|
|
|
|
use InteractsWithQueue;
|
|
|
|
use Queueable;
|
|
|
|
use SerializesModels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-05-16 16:19:14 +02:00
|
|
|
public function __construct(public Geolocatable $model)
|
2023-05-16 14:29:51 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$address = $this->model->getAddressForGeolocation();
|
|
|
|
|
|
|
|
if (!$address) {
|
|
|
|
$this->model->destroyCoordinate();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$coordinate = $address->getCoordinate();
|
|
|
|
|
|
|
|
if (!$coordinate) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->model->fillCoordinate($coordinate);
|
|
|
|
}
|
|
|
|
}
|