feat: 공정 관리 API 개선 및 ProcessItem 추가
- ProcessItem 모델 및 마이그레이션 추가 - Process 요청/서비스 로직 수정 - Swagger API 문서 추가 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
use App\Traits\ModelTrait;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -41,10 +42,29 @@ class Process extends Model
|
||||
];
|
||||
|
||||
/**
|
||||
* 공정 자동 분류 규칙
|
||||
* 공정 자동 분류 규칙 (패턴 규칙)
|
||||
*/
|
||||
public function classificationRules(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProcessClassificationRule::class)->orderBy('priority');
|
||||
}
|
||||
|
||||
/**
|
||||
* 공정-품목 연결 (중간 테이블)
|
||||
*/
|
||||
public function processItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(ProcessItem::class)->orderBy('priority');
|
||||
}
|
||||
|
||||
/**
|
||||
* 연결된 품목 (다대다)
|
||||
*/
|
||||
public function items(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Items\Item::class, 'process_items')
|
||||
->withPivot(['priority', 'is_active'])
|
||||
->withTimestamps()
|
||||
->orderByPivot('priority');
|
||||
}
|
||||
}
|
||||
|
||||
44
app/Models/ProcessItem.php
Normal file
44
app/Models/ProcessItem.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Items\Item;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* 공정-품목 연결 모델 (개별 품목 지정용)
|
||||
*/
|
||||
class ProcessItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'process_id',
|
||||
'item_id',
|
||||
'priority',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
'priority' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* 공정
|
||||
*/
|
||||
public function process(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Process::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 품목
|
||||
*/
|
||||
public function item(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Item::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user