- DB 연결: 로컬/Docker 환경 오버라이딩 설정 (.env) - 테넌트 위젯: redirect 버그 수정 (TenantSelectorWidget) - 통계 위젯: 사용자/제품/자재/주문 카드 추가 (StatsOverviewWidget) - 리소스 한국어화: Product, Material 모델 레이블 추가 - 대시보드: 위젯 등록 및 캐시 최적화 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
94 lines
2.2 KiB
PHP
94 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Design;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
class ModelParameter extends Model
|
|
{
|
|
use SoftDeletes, BelongsToTenant;
|
|
|
|
protected $table = 'model_parameters';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'model_id',
|
|
'parameter_name',
|
|
'parameter_type',
|
|
'is_required',
|
|
'default_value',
|
|
'min_value',
|
|
'max_value',
|
|
'unit',
|
|
'options',
|
|
'description',
|
|
'sort_order',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_required' => 'boolean',
|
|
'min_value' => 'decimal:6',
|
|
'max_value' => 'decimal:6',
|
|
'options' => 'array',
|
|
'sort_order' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 매개변수가 속한 모델
|
|
*/
|
|
public function designModel()
|
|
{
|
|
return $this->belongsTo(DesignModel::class, 'model_id');
|
|
}
|
|
|
|
/**
|
|
* 매개변수 타입별 검증
|
|
*/
|
|
public function validateValue($value)
|
|
{
|
|
switch ($this->parameter_type) {
|
|
case 'NUMBER':
|
|
if (!is_numeric($value)) {
|
|
return false;
|
|
}
|
|
if ($this->min_value !== null && $value < $this->min_value) {
|
|
return false;
|
|
}
|
|
if ($this->max_value !== null && $value > $this->max_value) {
|
|
return false;
|
|
}
|
|
return true;
|
|
|
|
case 'SELECT':
|
|
return in_array($value, $this->options ?? []);
|
|
|
|
case 'BOOLEAN':
|
|
return is_bool($value) || in_array($value, [0, 1, '0', '1', 'true', 'false']);
|
|
|
|
case 'TEXT':
|
|
return is_string($value);
|
|
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 매개변수 값 형변환
|
|
*/
|
|
public function castValue($value)
|
|
{
|
|
switch ($this->parameter_type) {
|
|
case 'NUMBER':
|
|
return (float) $value;
|
|
case 'BOOLEAN':
|
|
return (bool) $value;
|
|
case 'TEXT':
|
|
case 'SELECT':
|
|
default:
|
|
return (string) $value;
|
|
}
|
|
}
|
|
} |