ContainerResource.php 966 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Http\Resources\API;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class ContainerResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @return array<string, mixed>
  11. */
  12. public function toArray(Request $request): array
  13. {
  14. $content = $this->content($request->get("version", 0))->first();
  15. return [
  16. 'id' => $this->id,
  17. 'name' => $content?->name,
  18. 'library' => new LibrarySimpleResource($this->library),
  19. 'naming_rule' => new NamingRuleSimpleResource($this->namingRule),
  20. 'naming_rules' => $this->naming_rules,
  21. "doc_stage" => $this->doc_stage,
  22. "doc_type" => $this->doc_type,
  23. "version" => $this->version,
  24. "created_at" => (string)$this->created_at,
  25. "created_by" => new UserProfileResource($this->createdBy),
  26. ];
  27. }
  28. }