CourseResource.php 987 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. use App\Http\Api\UserApi;
  5. class CourseResource 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. return [
  16. "id"=>$this->id,
  17. "title"=> $this->title,
  18. "subtitle"=> $this->subtitle,
  19. "teacher"=> UserApi::getById($this->teacher),
  20. "course_count"=>10,
  21. "type"=> 1,
  22. "anthology_id"=> '',
  23. "start_at"=> $this->start_at,
  24. "end_at"=> $this->end_at,
  25. "content"=> $this->content,
  26. "content_type"=> $this->content_type,
  27. "cover"=> $this->cover,
  28. "created_at"=> $this->created_at,
  29. "updated_at"=> $this->updated_at,
  30. ];
  31. }
  32. }