New-Thanasoft/thanasoft-back/app/Http/Resources/Client/ClientCategoryResource.php
2025-10-09 18:25:02 +03:00

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')),
];
}
}