You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
844 B

  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class FileResource extends JsonResource
  5. {
  6. public function toArray($request)
  7. {
  8. $resource = [
  9. '_service' => 'user',
  10. '_resource' => 'files',
  11. ];
  12. foreach ($this->getAttributes() as $attribute => $value) {
  13. switch ($attribute) {
  14. case 'user_id':
  15. case 'business_id':
  16. case 'project_id':
  17. case 'disk':
  18. case 'original_name':
  19. case 'name':
  20. case 'extension':
  21. case 'mime':
  22. case 'size':
  23. case 'description':
  24. $resource[$attribute] = $value;
  25. break;
  26. }
  27. }
  28. return $resource;
  29. }
  30. }