kevin 284d228dc5 feat(vehicle): add vehicle+convoy feature with API, models, repos, UI
Adds model, repo, controller, and request classes for Vehicle and Convoy.
Registers routes for vehicles and convoys, updates client store.
Adds front‑end files to list, add, edit vehicles.
Cleans up console logging from client store.
2026-04-15 17:27:40 +03:00

80 lines
3.8 KiB
PHP

<?php
namespace App\Http\Resources\Convoy;
use App\Http\Resources\Client\ClientResource;
use App\Http\Resources\Deceased\DeceasedResource;
use App\Http\Resources\Vehicle\VehicleResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ConvoyResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'deceased_id' => $this->deceased_id,
'client_id' => $this->client_id,
'vehicle_id' => $this->vehicle_id,
'mission_title' => $this->mission_title,
'convoy_type' => $this->convoy_type,
'transport_mode' => $this->transport_mode,
'status' => $this->status,
'planned_start_at' => $this->planned_start_at?->format('Y-m-d H:i:s'),
'estimated_end_at' => $this->estimated_end_at?->format('Y-m-d H:i:s'),
'family_email' => $this->family_email,
'automatic_notifications' => $this->automatic_notifications,
'departure' => [
'location_selection_mode' => $this->departure_location_selection_mode,
'location_id' => $this->departure_location_id,
'location' => $this->whenLoaded('departureLocation', function () {
return $this->departureLocation ? [
'id' => $this->departureLocation->id,
'client_id' => $this->departureLocation->client_id,
'name' => $this->departureLocation->name,
'address_line1' => $this->departureLocation->address_line1,
'address_line2' => $this->departureLocation->address_line2,
'postal_code' => $this->departureLocation->postal_code,
'city' => $this->departureLocation->city,
'country_code' => $this->departureLocation->country_code,
'gps_lat' => $this->departureLocation->gps_lat,
'gps_lng' => $this->departureLocation->gps_lng,
] : null;
}),
'name' => $this->departure_name,
'address' => $this->departure_address,
'city' => $this->departure_city,
'postal_code' => $this->departure_postal_code,
'country_code' => $this->departure_country_code,
'latitude' => $this->departure_latitude,
'longitude' => $this->departure_longitude,
'additional_details' => $this->departure_additional_details,
],
'tabs' => [
'itinerary' => $this->tab_itinerary,
'legal_documents' => $this->tab_legal_documents,
'team_resources' => $this->tab_team_resources,
'procedures' => $this->tab_procedures,
'cost_tracking' => $this->tab_cost_tracking,
'fuel' => $this->tab_fuel,
'ceremony' => $this->tab_ceremony,
'thanatopraxy' => $this->tab_thanatopraxy,
'gps_tracking_steps' => $this->tab_gps_tracking_steps,
'communication' => $this->tab_communication,
],
'deceased' => $this->whenLoaded('deceased', function () {
return new DeceasedResource($this->deceased);
}),
'client' => $this->whenLoaded('client', function () {
return $this->client ? new ClientResource($this->client) : null;
}),
'vehicle' => $this->whenLoaded('vehicle', function () {
return $this->vehicle ? new VehicleResource($this->vehicle) : null;
}),
'created_at' => $this->created_at?->format('Y-m-d H:i:s'),
'updated_at' => $this->updated_at?->format('Y-m-d H:i:s'),
];
}
}