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

25 lines
620 B
PHP
Raw Normal View History

2022-04-17 11:25:55 +00:00
<?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 [
2022-04-20 10:33:14 +00:00
'id' => $this->product_id ?? $this->id,
2022-04-17 11:27:21 +00:00
'type' => $this->suggestion_type,
2022-04-17 11:25:55 +00:00
'name' => $this->name,
2022-05-03 12:22:04 +00:00
$this->mergeWhen($this->suggestion_type === 'category',['description' => $this->description])
2022-05-03 12:14:55 +00:00
2022-04-17 11:25:55 +00:00
];
}
}