38 lines
730 B
PHP
38 lines
730 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UnitEquivalence extends Model
|
|
{
|
|
protected $fillable = [
|
|
'inventory_id',
|
|
'unit_of_measure_id',
|
|
'conversion_factor',
|
|
'retail_price',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'conversion_factor' => 'decimal:3',
|
|
'retail_price' => 'decimal:2',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function inventory()
|
|
{
|
|
return $this->belongsTo(Inventory::class);
|
|
}
|
|
|
|
public function unitOfMeasure()
|
|
{
|
|
return $this->belongsTo(UnitOfMeasurement::class);
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
}
|