AttachmentResource.php 923 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. use Illuminate\Support\Facades\Storage;
  5. class AttachmentResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  12. */
  13. public function toArray($request)
  14. {
  15. $data = [
  16. "id" => $this->id,
  17. "user_uid" => $this->user_uid,
  18. "name" => $this->name,
  19. "title" => $this->title,
  20. "size" => $this->size,
  21. "content_type" => $this->content_type,
  22. "url" => Storage::disk('public')->url($this->bucket.'/'.$this->name),
  23. "status" => $this->status,
  24. "created_at" => $this->created_at,
  25. "updated_at" => $this->updated_at,
  26. ];
  27. return $data;
  28. }
  29. }