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.

34 lines
757 B

  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class CommentResource extends JsonResource
  5. {
  6. /**
  7. * Transform the resource into an array.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @return array
  11. */
  12. public function toArray($request)
  13. {
  14. $resource = [
  15. '_service' => 'task',
  16. '_resource' => 'comment',
  17. ];
  18. foreach ($this->getAttributes() as $attribute => $value) {
  19. switch ($attribute) {
  20. case 'task_id' :
  21. case 'user_id' :
  22. case 'body' :
  23. $resource[$attribute] = $value;
  24. break;
  25. }
  26. }
  27. return $resource;
  28. }
  29. }