NotificationSendResource.php 767 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Http\Resources;
  3. use Carbon\Carbon;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Http\Resources\Json\JsonResource;
  6. class NotificationSendResource extends JsonResource
  7. {
  8. public function toArray(Request $request): array
  9. {
  10. return [
  11. 'id' => $this->id,
  12. 'notification_id' => $this->notification_id,
  13. 'notification' => $this->whenLoaded('notification', fn() => new NotificationResource($this->notification)),
  14. 'user_id' => $this->user_id,
  15. 'read' => $this->read,
  16. 'read_at' => $this->read_at?->format('Y-m-d H:i:s'),
  17. 'created_at' => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
  18. ];
  19. }
  20. }