ContainerResource.php 1023 B

123456789101112131415161718192021222324252627282930313233
  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. 'approval_status' => $this->approval_status,
  25. "created_at" => (string)$this->created_at,
  26. "created_by" => new UserProfileResource($this->createdBy),
  27. ];
  28. }
  29. }