ProjectResource.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. use App\Http\Api\UserApi;
  5. use App\Http\Api\StudioApi;
  6. use App\Http\Api\ProjectApi;
  7. class ProjectResource extends JsonResource
  8. {
  9. /**
  10. * Transform the resource into an array.
  11. *
  12. * @param \Illuminate\Http\Request $request
  13. * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
  14. */
  15. public function toArray($request)
  16. {
  17. $data = [
  18. 'id' => $this->uid,
  19. 'title' => $this->title,
  20. 'type' => $this->type,
  21. 'description' => $this->description,
  22. 'executors_id' => json_decode($this->executors_id),
  23. 'parent_id' => $this->parent_id,
  24. 'parent' => ProjectApi::getById($this->parent_id),
  25. 'path' => ProjectApi::getListByIds(json_decode($this->path)),
  26. 'description' => $this->description,
  27. "owner" => StudioApi::getById($this->owner_id),
  28. "editor" => UserApi::getIdByUuid($this->editor_id),
  29. 'created_at' => $this->created_at,
  30. 'updated_at' => $this->updated_at,
  31. ];
  32. return $data;
  33. }
  34. }