59 lines
1.2 KiB
PHP
59 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Maintenance\Models;
|
|
|
|
use App\Business;
|
|
use App\Contact;
|
|
use App\Product;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class SparePart extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'maintenance_spare_parts';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'product_id',
|
|
'warehouse_id',
|
|
'supplier_id',
|
|
'part_number',
|
|
'name',
|
|
'quantity',
|
|
'min_stock',
|
|
'max_stock',
|
|
'purchase_price',
|
|
'unit',
|
|
'notes',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:3',
|
|
'min_stock' => 'decimal:3',
|
|
'max_stock' => 'decimal:3',
|
|
'purchase_price' => 'integer',
|
|
];
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
public function supplier()
|
|
{
|
|
return $this->belongsTo(Contact::class, 'supplier_id');
|
|
}
|
|
|
|
public function consumptions()
|
|
{
|
|
return $this->hasMany(SparePartConsumption::class, 'spare_part_id');
|
|
}
|
|
}
|