| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Http\Resources;
- use Carbon\Carbon;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class NotificationResource extends JsonResource
- {
- public function toArray(Request $request): array
- {
- return [
- 'id' => $this->id,
- 'type' => $this->type,
- 'source' => $this->source,
- 'source_id' => $this->source_id,
- 'title' => $this->title,
- 'message' => $this->message,
- 'recipient' => $this->recipient,
- 'recipient_position' => $this->recipient_position,
- 'recipient_sector' => $this->recipient_sector,
- 'created_by' => $this->created_by,
- 'created_by_user' => $this->whenLoaded('createdBy', fn() => new UserResource($this->createdBy)),
- 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
- 'updated_at' => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),
- ];
- }
- }
|