ChannelResource.php 918 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. use App\Http\Api\StudioApi;
  5. class ChannelResource 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. "uid" => $this->uid,
  17. "name" => $this->name,
  18. "summary" => $this->summary,
  19. "type" => $this->type,
  20. "studio" => StudioApi::getById($this->owner_uid),
  21. "lang" => $this->lang,
  22. "status" => $this->status,
  23. "created_at" => $this->created_at,
  24. "updated_at" => $this->updated_at,
  25. ];
  26. if(isset($this->role)){
  27. $data["role"] = $this->role;
  28. }
  29. return $data;
  30. }
  31. }