41 lines
1022 B
PHP
41 lines
1022 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Mission;
|
|
use App\Services\PolylineEncoder;
|
|
use Illuminate\Console\Command;
|
|
|
|
class EncodePolyLineCommand extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'polyline:encode';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'encode all missions that have poly line';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(PolylineEncoder $polylineEncoder): void
|
|
{
|
|
Mission::query()->whereNotNull('area')->each(function ($mission) use ($polylineEncoder) {
|
|
$area = json_decode($mission->area, true);
|
|
$encodedValue = $polylineEncoder->encodePolyLine($area['coordinates'], lng_lat_format:true);
|
|
$mission->update([
|
|
'encoded_route' => $encodedValue,
|
|
]);
|
|
});
|
|
|
|
$this->info("updated successfully");
|
|
}
|
|
}
|