28 lines
659 B
PHP
28 lines
659 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\WeightEntry;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/** @mixin WeightEntry */
|
|
class WeightEntryResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'weightKg' => $this->weight_kg,
|
|
'source' => $this->source,
|
|
'measuredAt' => $this->measured_at?->toISOString(),
|
|
'createdAt' => $this->created_at?->toISOString(),
|
|
];
|
|
}
|
|
}
|