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

34 lines
1.2 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class RiceShrimpIndustryResource 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,
'year' => $this->year,
'quarter' => $this->quarter,
'area' => trim_trailing_zero($this->area),
'area_unit' => $this->area_unit,
'product_output' => trim_trailing_zero($this->product_output),
'product_output_unit' => $this->product_output_unit,
'product_value' => trim_trailing_zero($this->product_value),
'product_value_unit' => $this->product_value_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(),
];
}
}