2
0

ChannelResource.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. "is_system" => $this->is_system,
  23. "status" => $this->status,
  24. "created_at" => $this->created_at,
  25. "updated_at" => $this->updated_at,
  26. ];
  27. if (isset($this->progress)) {
  28. $data["progress"] = $this->progress;
  29. }
  30. if (isset($this->role)) {
  31. $data["role"] = $this->role;
  32. }
  33. return $data;
  34. }
  35. }