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',
|
||||
];
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Machines\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Machines Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $machine_counter_id
|
||||
* @property int $reading_milli
|
||||
* @property int $user_id
|
||||
* @property Carbon $read_at
|
||||
*/
|
||||
#[Table('machine_counter_readings')]
|
||||
#[Fillable(['machine_counter_id', 'reading_milli', 'user_id', 'read_at'])]
|
||||
class MachineCounterReadingModel extends Model
|
||||
{
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'machine_counter_id' => 'integer',
|
||||
'reading_milli' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
'read_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Machines\Infrastructure\Persistence\Eloquent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Persistence model, used only inside the Machines Infrastructure layer.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $machine_id
|
||||
* @property string $planned_on Y-m-d, kept as text so that it compares as a date in every database.
|
||||
* @property int $position
|
||||
* @property int|null $task_id
|
||||
* @property int|null $quick_sale_order_line_id
|
||||
* @property int|null $production_step_position
|
||||
* @property Carbon|null $completed_at
|
||||
* @property int|null $completed_by
|
||||
*/
|
||||
#[Table('machine_queue_entries')]
|
||||
#[Fillable(['machine_id', 'planned_on', 'position', 'task_id', 'quick_sale_order_line_id', 'production_step_position', 'completed_at', 'completed_by'])]
|
||||
class MachineQueueEntryModel extends Model
|
||||
{
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'machine_id' => 'integer',
|
||||
'position' => 'integer',
|
||||
'task_id' => 'integer',
|
||||
'quick_sale_order_line_id' => 'integer',
|
||||
'production_step_position' => 'integer',
|
||||
'completed_at' => 'immutable_datetime',
|
||||
'completed_by' => 'integer',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user