Files
backend/app/Console/Commands/EncodePolyLineCommand.php
2026-06-14 10:05:13 +03:30

41 lines
1.0 KiB
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 = 'app:encode-poly-line-command';
/**
* 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");
}
}