diff --git a/app/Models/Item.php b/app/Models/Item.php index e906241..7d62993 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -12,6 +12,7 @@ class Item extends Model protected $fillable = [ 'plant_id', + 'line_id', 'category', 'code', 'description', @@ -19,11 +20,16 @@ class Item extends Model 'uom', ]; - public function plant(): BelongsTo + public function plant() { return $this->belongsTo(Plant::class); } + public function item() + { + return $this->belongsTo(Item::class, 'item_id', 'id'); + } + public function stickerMasters() { return $this->hasMany(StickerMaster::class, 'item_id', 'id'); diff --git a/app/Models/Line.php b/app/Models/Line.php index 22f539a..435dd4b 100644 --- a/app/Models/Line.php +++ b/app/Models/Line.php @@ -3,30 +3,32 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\SoftDeletes; class Line extends Model { use SoftDeletes; protected $fillable = [ - "plant_id", - "name", - "type", - "group_work_center", - "no_of_operation", - "work_group1_id", - "work_group2_id", - "work_group3_id", - "work_group4_id", - "work_group5_id", - "work_group6_id", - "work_group7_id", - "work_group8_id", - "work_group9_id", - "work_group10_id", + 'plant_id', + 'block_id', + 'name', + 'type', + 'line_capacity', + 'group_work_center', + 'no_of_operation', + 'work_group1_id', + 'work_group2_id', + 'work_group3_id', + 'work_group4_id', + 'work_group5_id', + 'work_group6_id', + 'work_group7_id', + 'work_group8_id', + 'work_group9_id', + 'work_group10_id', ]; public function plant(): BelongsTo @@ -34,6 +36,11 @@ class Line extends Model return $this->belongsTo(Plant::class); } + public function block(): BelongsTo + { + return $this->belongsTo(Block::class); + } + public function testingPanelReadings() { return $this->hasMany(TestingPanelReading::class); diff --git a/app/Models/ProductionPlan.php b/app/Models/ProductionPlan.php index 35bbb39..66f28d1 100644 --- a/app/Models/ProductionPlan.php +++ b/app/Models/ProductionPlan.php @@ -16,9 +16,12 @@ class ProductionPlan extends Model protected $fillable = [ 'plant_id', 'shift_id', + 'item_id', 'line_id', 'plan_quantity', 'production_quantity', + 'working_days', + 'leave_dates', 'operator_id', 'created_at', 'updated_at', @@ -39,6 +42,11 @@ class ProductionPlan extends Model return $this->belongsTo(Line::class); } + public function item(): BelongsTo + { + return $this->belongsTo(Item::class); + } + public function prunable(): Builder { return static::where('created_at', '<=', now()->subMonthsNoOverflow(6)); diff --git a/app/Models/ProductionQuantity.php b/app/Models/ProductionQuantity.php index 88cef82..ff29cf3 100644 --- a/app/Models/ProductionQuantity.php +++ b/app/Models/ProductionQuantity.php @@ -22,6 +22,7 @@ class ProductionQuantity extends Model 'shift_id', 'line_id', 'item_id', + 'machine_id', 'serial_number', 'production_order', 'operator_id', @@ -53,6 +54,11 @@ class ProductionQuantity extends Model return $this->belongsTo(Item::class); } + public function machine(): BelongsTo + { + return $this->belongsTo(Machine::class); + } + protected static function booted() { static::created(function ($productionQuantity) {