26 lines
774 B
PHP
26 lines
774 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ServiceAreaResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->uuid,
|
|
'db_id' => $this->id,
|
|
'name' => $this->name,
|
|
'code' => $this->code,
|
|
'status' => $this->status,
|
|
'description' => $this->description,
|
|
'barangay_count' => $this->whenCounted('barangays'),
|
|
'barangays' => BarangayResource::collection($this->whenLoaded('barangays')),
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
'updated_at' => $this->updated_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|