12345678910111213141516171819202122232425262728 |
- <?php
- namespace App\Http\Resources\API;
- use App\Models\RequirementGroup;
- use Illuminate\Http\Request;
- use Illuminate\Http\Resources\Json\JsonResource;
- class RequirementGroupResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @return array<string, mixed>
- */
- public function toArray(Request $request): array
- {
- //return parent::toArray($request);
- return[
- 'id'=>$this->id,
- 'name'=>$this->name,
- 'asset_id'=>$this->asset_id,
- 'abbr_name'=>$this->abbr_name,
- 'parent_id' => $this->parent_id,
- 'children' =>$this->parent_id == 0 ? RequirementGroupResource::collection($this->children) : [],
- ];
- }
- }
|