FileUploadSuccessResource.php 654 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Resources\API;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. use Illuminate\Support\Facades\Storage;
  6. class FileUploadSuccessResource extends JsonResource
  7. {
  8. /**
  9. * Transform the resource into an array.
  10. *
  11. * @return array<string, mixed>
  12. */
  13. public function toArray(Request $request): array
  14. {
  15. return [
  16. 'id' => $this->id,
  17. 'title' => $this->title,
  18. 'url' => Storage::url($this->pathname),
  19. 'extension' => $this->extension,
  20. 'size' => $this->size,
  21. 'is_bim' => $this->is_bim,
  22. ];
  23. }
  24. }