ChannelResource.php 904 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class ChannelResource extends JsonResource
  5. {
  6. /**
  7. * Transform the resource into an array.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  11. */
  12. public function toArray($request)
  13. {
  14. $data = [
  15. "uid" => $this->uid,
  16. "name" => $this->name,
  17. "summary" => $this->summary,
  18. "type" => $this->type,
  19. "studio" => \App\Http\Api\StudioApi::getById($this->owner_uid),
  20. "lang" => $this->lang,
  21. "status" => $this->status,
  22. "created_at" => $this->created_at,
  23. "updated_at" => $this->updated_at,
  24. ];
  25. if(isset($this->role)){
  26. $data["role"] = $this->role;
  27. }
  28. return $data;
  29. }
  30. }