66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Quote;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 수식 매핑 값 모델
|
||
|
|
*
|
||
|
|
* @property int $id
|
||
|
|
* @property int $formula_id
|
||
|
|
* @property string $source_variable
|
||
|
|
* @property string $source_value
|
||
|
|
* @property string $result_value
|
||
|
|
* @property string $result_type
|
||
|
|
* @property int $sort_order
|
||
|
|
*/
|
||
|
|
class QuoteFormulaMapping extends Model
|
||
|
|
{
|
||
|
|
protected $table = 'quote_formula_mappings';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'formula_id',
|
||
|
|
'source_variable',
|
||
|
|
'source_value',
|
||
|
|
'result_value',
|
||
|
|
'result_type',
|
||
|
|
'sort_order',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'sort_order' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $attributes = [
|
||
|
|
'result_type' => 'fixed',
|
||
|
|
'sort_order' => 0,
|
||
|
|
];
|
||
|
|
|
||
|
|
public const RESULT_FIXED = 'fixed';
|
||
|
|
|
||
|
|
public const RESULT_FORMULA = 'formula';
|
||
|
|
|
||
|
|
// =========================================================================
|
||
|
|
// Relationships
|
||
|
|
// =========================================================================
|
||
|
|
|
||
|
|
public function formula(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(QuoteFormula::class, 'formula_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
// =========================================================================
|
||
|
|
// Helper Methods
|
||
|
|
// =========================================================================
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 매핑 조건 표시 문자열
|
||
|
|
*/
|
||
|
|
public function getConditionLabelAttribute(): string
|
||
|
|
{
|
||
|
|
return "{$this->source_variable} = '{$this->source_value}'";
|
||
|
|
}
|
||
|
|
}
|