lcly-data-admin/app/Http/Resources/MaterielResource.php

33 lines
1007 B
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' => $this->lowest_price,
'highest_price' => $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(),
];
}
}