33 lines
946 B
PHP
33 lines
946 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Client;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ClientCategoryResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'slug' => $this->slug,
|
|
'description' => $this->description,
|
|
'is_active' => $this->is_active,
|
|
'sort_order' => $this->sort_order,
|
|
'created_at' => $this->created_at?->toISOString(),
|
|
'updated_at' => $this->updated_at?->toISOString(),
|
|
|
|
// Relationships (loaded when needed)
|
|
// 'clients_count' => $this->whenCounted('clients'),
|
|
// 'clients' => ClientResource::collection($this->whenLoaded('clients')),
|
|
];
|
|
}
|
|
}
|