FleetCart/Modules/Variation/Transformers/VariationResource.php
2023-12-03 14:07:47 +00:00

29 lines
692 B
PHP

<?php
namespace Modules\Variation\Transformers;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class VariationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param Request $request
*
* @return array
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'uid' => $this->uid,
'name' => $this->name,
'type' => $this->type,
'is_global' => $this->is_global,
'values' => VariationValueResource::collection($this->values->sortBy('position')),
];
}
}