Skip to content

Commit

Permalink
fix: Foodrecord resource
Browse files Browse the repository at this point in the history
  • Loading branch information
amrron committed Oct 21, 2024
1 parent 9fc93ee commit d6876d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions app/Http/Resources/FoodRecordResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;

class FoodRecordResource extends JsonResource
{
Expand All @@ -18,12 +19,12 @@ public function toArray(Request $request): array
'id' => $this->id,
'nama' => $this->name,
'jumlah' => $this->jumlah,
'waktu' => $this->waktu,
'karbohidrat' => $this->karbohidrat,
'protein' => $this->protein,
'lemak' => $this->lemak,
'gula' => $this->gula,
'garam' => $this->garam,
'waktu' => Carbon::parse($this->waktu)->format('H:i'),
'karbohidrat' => $this->karbohidrat * $this->jumlah,
'protein' => $this->protein * $this->jumlah,
'lemak' => $this->lemak * $this->jumlah,
'gula' => $this->gula * $this->jumlah,
'garam' => $this->garam * $this->jumlah,
];
}
}

0 comments on commit d6876d2

Please sign in to comment.