- **Trip Incidents**: Created the `AdminTripController@incidents` API endpoint, built the `incidents.blade.php` view, enabled the incidents sidebar link, and added test coverage (`TripIncidentDashboardTest.php`). - **Drop-off Points (LGU Geofence)**: Added a Barangay (LGU) dropdown to the drop-off point form. Integrated `Turf.js` to render the LGU boundary polygon on Leaflet and restrict pin placement (clicks, drags, and address search) to within the selected boundary. - **Trip Calendar**: Changed the shortcut for opening the Daily Digest from Ctrl+Click to Shift+Click on calendar dates. - **API fixes**: Corrected the Barangay fetch endpoint to `/api/v1/geo/barangays` in the Drop-off points view.
39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TripTimelineEventResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'event_type' => $this->event_type,
|
|
'event_at' => $this->event_at?->toIso8601String(),
|
|
'coordinates' => $this->coordinates ? [
|
|
'lat' => $this->coordinates->latitude,
|
|
'lng' => $this->coordinates->longitude,
|
|
] : null,
|
|
'recorded_by' => $this->whenLoaded('recordedBy', fn () => [
|
|
'id' => $this->recordedBy?->uuid,
|
|
'name' => $this->recordedBy?->full_name,
|
|
]),
|
|
'trip' => $this->whenLoaded('trip', fn () => [
|
|
'id' => $this->trip?->id,
|
|
'trip_number' => $this->trip?->trip_number,
|
|
'route_name' => $this->trip?->route?->name,
|
|
'team_name' => $this->trip?->team?->name,
|
|
'driver_name' => $this->trip?->team?->driver?->full_name,
|
|
'truck_plate' => $this->trip?->truck?->plate_number,
|
|
]),
|
|
'related_type' => $this->related_type,
|
|
'related_id' => $this->related_id,
|
|
'metadata' => $this->metadata,
|
|
'notes' => $this->notes,
|
|
];
|
|
}
|
|
}
|