sarga/packages/Sarga/API/Http/Resources/Catalog/Suggestion.php

25 lines
620 B
PHP

<?php
namespace Sarga\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class Suggestion extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request): array
{
return [
'id' => $this->product_id ?? $this->id,
'type' => $this->suggestion_type,
'name' => $this->name,
$this->mergeWhen($this->suggestion_type === 'category',['description' => $this->description])
];
}
}