31 lines
918 B
PHP
31 lines
918 B
PHP
<?php
|
|
|
|
namespace TPS\Birzha\Classes;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ProductResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name_ru' => $this->getAttributeTranslated('name', 'ru'),
|
|
'name_en' => $this->getAttributeTranslated('name', 'en'),
|
|
'category_id' => $this->categories()->first()->id,
|
|
'productForEditing' => $this->id,
|
|
'quantity' => $this->quantity,
|
|
'price' => $this->price,
|
|
'place' => $this->place,
|
|
'description_tm' => $this->getAttributeTranslated('description', 'tm'),
|
|
'description_ru' => $this->getAttributeTranslated('description', 'ru'),
|
|
|
|
];
|
|
}
|
|
} |