feat: Add Geofence Leaflet drawing tool for DOPs and Dumpsites
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user