42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class DropOffPointResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'db_id' => $this->id,
|
|
'name' => $this->name,
|
|
'code' => $this->code,
|
|
'address_line' => $this->address_line,
|
|
'coordinates' => $this->coordinates ? [
|
|
'lat' => $this->coordinates->latitude,
|
|
'lng' => $this->coordinates->longitude,
|
|
] : null,
|
|
'geofence' => $this->geofence,
|
|
'capacity_kg' => $this->capacity_kg,
|
|
'operating_hours' => $this->operating_hours,
|
|
'accepted_waste_types' => $this->accepted_waste_types,
|
|
'status' => $this->status,
|
|
'photo_path' => $this->photo_path,
|
|
'contact_person' => $this->contact_person,
|
|
'contact_phone' => $this->contact_phone,
|
|
'distance_meters' => $this->when(
|
|
isset($this->distance_meters),
|
|
fn () => round((float) $this->distance_meters, 1),
|
|
),
|
|
'tenant' => $this->whenLoaded('tenant', fn () => [
|
|
'id' => $this->tenant->id,
|
|
'name' => $this->tenant->name,
|
|
]),
|
|
'barangay' => BarangayResource::make($this->whenLoaded('barangay')),
|
|
];
|
|
}
|
|
}
|