Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| OriginResource | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Category\Resources; |
| 4 | |
| 5 | use Illuminate\Http\Request; |
| 6 | use Illuminate\Http\Resources\Json\JsonResource; |
| 7 | |
| 8 | /** |
| 9 | * @property int $id |
| 10 | * @property string $name |
| 11 | * @property string $integration_code |
| 12 | * @property string $observation |
| 13 | * @property int $priority_field |
| 14 | * @property int $priority_order |
| 15 | */ |
| 16 | class OriginResource extends JsonResource |
| 17 | { |
| 18 | /** |
| 19 | * Transform the resource into an array. |
| 20 | * |
| 21 | * @param Request $request |
| 22 | * @return array |
| 23 | */ |
| 24 | public function toArray(Request $request): array |
| 25 | { |
| 26 | return [ |
| 27 | 'id' => $this->id, |
| 28 | 'name' => $this->name, |
| 29 | 'observation' => $this->observation, |
| 30 | 'priority_field' => $this->priority_field, |
| 31 | 'priority_order' => $this->priority_order, |
| 32 | 'families' => FamilyResource::collection($this->whenLoaded('families')), |
| 33 | ]; |
| 34 | } |
| 35 | } |