create service count floor level and retributions
This commit is contained in:
55
app/Models/MasterParameter.php
Normal file
55
app/Models/MasterParameter.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MasterParameter extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'parameter_code',
|
||||
'parameter_name',
|
||||
'default_value',
|
||||
'unit',
|
||||
'description',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'default_value' => 'decimal:6',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relationship to FormulaParameter
|
||||
*/
|
||||
public function formulaParameters()
|
||||
{
|
||||
return $this->hasMany(FormulaParameter::class, 'parameter_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship to MasterFormula through FormulaParameter
|
||||
*/
|
||||
public function formulas()
|
||||
{
|
||||
return $this->belongsToMany(MasterFormula::class, 'formula_parameters', 'parameter_id', 'formula_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope untuk mencari berdasarkan parameter code
|
||||
*/
|
||||
public function scopeByCode($query, $code)
|
||||
{
|
||||
return $query->where('parameter_code', $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method untuk mendapatkan nilai parameter dengan fallback ke default
|
||||
*/
|
||||
public function getValue($customValue = null)
|
||||
{
|
||||
return $customValue !== null ? $customValue : $this->default_value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user