39 lines
813 B
PHP
39 lines
813 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUlids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class WeightEntry extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\WeightEntryFactory> */
|
|
use HasFactory, HasUlids;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'weight_kg',
|
|
'source',
|
|
'measured_at',
|
|
];
|
|
|
|
protected $attributes = [
|
|
'source' => 'manual',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'weight_kg' => 'float',
|
|
'measured_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|