Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| AddressPermissionResource | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Address\Resources; |
| 4 | |
| 5 | use Domain\Category\Resources\FamilyResource; |
| 6 | use Domain\Category\Resources\OriginResource; |
| 7 | use Domain\Product\Resources\ProductResource; |
| 8 | use Domain\Storage\Enums\StorageTypeEnum; |
| 9 | use Illuminate\Http\Request; |
| 10 | use Illuminate\Http\Resources\Json\JsonResource; |
| 11 | |
| 12 | /** |
| 13 | * @property int $id |
| 14 | * @property ?StorageTypeEnum $storage_type |
| 15 | * @property string $created_at |
| 16 | * @property string $updated_at |
| 17 | */ |
| 18 | class AddressPermissionResource extends JsonResource |
| 19 | { |
| 20 | public function toArray(Request $request): array |
| 21 | { |
| 22 | return [ |
| 23 | 'id' => $this->id, |
| 24 | 'storage_type' => $this->storage_type?->value, |
| 25 | 'family' => FamilyResource::make($this->whenLoaded('family')), |
| 26 | 'origin' => OriginResource::make($this->whenLoaded('origin')), |
| 27 | 'product' => ProductResource::make($this->whenLoaded('product')), |
| 28 | 'owner' => AddressResource::make($this->whenLoaded('owner')), |
| 29 | 'created_at' => (string)$this->created_at, |
| 30 | 'updated_at' => (string)$this->updated_at, |
| 31 | ]; |
| 32 | } |
| 33 | } |