| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Http\Resources;
- use App\Models\SupportRequest;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
- use Illuminate\Http\Resources\Json\JsonResource;
- class SupportRequestResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'user_id' => $this->user_id,
- 'user_type' => $this->user_type,
- 'name' => $this->name,
- 'email' => $this->email,
- 'phone' => $this->phone,
- 'category' => $this->category,
- 'title' => $this->title,
- 'message' => $this->message,
- 'status' => $this->status?->value,
- 'handled_by' => $this->handled_by,
- 'handler' => $this->whenLoaded('handler', fn () => $this->handler?->name),
- 'resolved_at' => $this->resolved_at?->format('d/m/Y H:i'),
- 'created_at' => $this->created_at?->format('d/m/Y H:i'),
- 'updated_at' => $this->updated_at?->format('d/m/Y H:i'),
- ];
- }
- public static function collection($resource): AnonymousResourceCollection
- {
- return parent::collection($resource);
- }
- }
|