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,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Machines\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use App\Modules\Machines\Domain\Enums\MachineType;
|
||||
use Database\Factories\MachineFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Machines Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property MachineType $type
|
||||
* @property string|null $description
|
||||
* @property int|null $responsible_user_id
|
||||
* @property bool $is_active
|
||||
*/
|
||||
#[Table('machines')]
|
||||
#[Fillable(['name', 'type', 'description', 'responsible_user_id', 'is_active'])]
|
||||
#[UseFactory(MachineFactory::class)]
|
||||
class MachineModel extends Model
|
||||
{
|
||||
/** @use HasFactory<MachineFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @return HasMany<MachineCounterModel, $this>
|
||||
*/
|
||||
public function counters(): HasMany
|
||||
{
|
||||
return $this->hasMany(MachineCounterModel::class, 'machine_id')->orderBy('sort_order');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => MachineType::class,
|
||||
'responsible_user_id' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user