feat: Add Geofence Leaflet drawing tool for DOPs and Dumpsites

This commit is contained in:
Developer
2026-06-30 13:31:36 +08:00
parent 54de35b03d
commit 92f8ee95fc
12 changed files with 214 additions and 83 deletions

View File

@@ -14,7 +14,9 @@ use App\Services\DropOff\DropOffPointFinder;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use MatanYadaev\EloquentSpatial\Objects\LineString;
use MatanYadaev\EloquentSpatial\Objects\Point;
use MatanYadaev\EloquentSpatial\Objects\Polygon;
class AdminDropOffPointController extends ApiController
{
@@ -73,6 +75,7 @@ class AdminDropOffPointController extends ApiController
'photo_path' => $data['photo_path'] ?? null,
'contact_person' => $data['contact_person'] ?? null,
'contact_phone' => $data['contact_phone'] ?? null,
'geofence' => !empty($data['geofence_wkt']) ? Polygon::fromJson($data['geofence_wkt'], 4326) : null,
]);
return $this->created(new DropOffPointResource($dop->load('barangay')), 'Drop-off point created');
@@ -100,6 +103,11 @@ class AdminDropOffPointController extends ApiController
}
unset($data['lat'], $data['lng']);
if (array_key_exists('geofence_wkt', $data)) {
$data['geofence'] = !empty($data['geofence_wkt']) ? Polygon::fromJson($data['geofence_wkt'], 4326) : null;
unset($data['geofence_wkt']);
}
DB::transaction(function () use ($dropOffPoint, $data, $oldStatus, $newStatus) {
$dropOffPoint->update($data);