33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class TruckResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'db_id' => $this->id,
|
|
'plate_number' => $this->plate_number,
|
|
'model' => $this->model,
|
|
'capacity_kg' => $this->capacity_kg,
|
|
'status' => $this->status,
|
|
'assigned_team_id' => $this->assigned_team_id,
|
|
'last_known_coordinates' => $this->last_known_coordinates ? [
|
|
'lat' => $this->last_known_coordinates->latitude,
|
|
'lng' => $this->last_known_coordinates->longitude,
|
|
] : null,
|
|
'last_location_updated_at' => $this->last_location_updated_at?->toIso8601String(),
|
|
'tenant' => $this->whenLoaded('tenant', fn () => [
|
|
'id' => $this->tenant->id,
|
|
'uuid' => $this->tenant->uuid,
|
|
'name' => $this->tenant->name,
|
|
]),
|
|
];
|
|
}
|
|
}
|