33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class MaterielResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'type' => $this->type,
|
|
'year' => $this->year,
|
|
'quarter' => $this->quarter,
|
|
'lowest_price' => trim_trailing_zero($this->lowest_price),
|
|
'highest_price' => trim_trailing_zero($this->highest_price),
|
|
'unit' => $this->unit,
|
|
'created_by' => AdminUserResource::make($this->whenLoaded('createdBy')),
|
|
'updated_by' => AdminUserResource::make($this->whenLoaded('updatedBy')),
|
|
'created_at' => $this->created_at->unix(),
|
|
'updated_at' => $this->updated_at->unix(),
|
|
];
|
|
}
|
|
}
|