Add machines with day-by-day work lists for job tasks
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Machines\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use App\Modules\Machines\Domain\Enums\CounterUnit;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Machines Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $machine_id
|
||||
* @property string $name
|
||||
* @property CounterUnit $unit
|
||||
* @property int $sort_order
|
||||
*/
|
||||
#[Table('machine_counters')]
|
||||
#[Fillable(['machine_id', 'name', 'unit', 'sort_order'])]
|
||||
class MachineCounterModel extends Model
|
||||
{
|
||||
/**
|
||||
* @return HasOne<MachineCounterReadingModel, $this>
|
||||
*/
|
||||
public function latestReading(): HasOne
|
||||
{
|
||||
return $this->hasOne(MachineCounterReadingModel::class, 'machine_counter_id')->latestOfMany('read_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'machine_id' => 'integer',
|
||||
'unit' => CounterUnit::class,
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user