36 lines
857 B
PHP
36 lines
857 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
|
|
|
|
class Part extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'part_number',
|
|
'name',
|
|
'description',
|
|
'cost',
|
|
'quantity_in_stock',
|
|
'reorder_level',
|
|
'location',
|
|
'manufacturer',
|
|
];
|
|
|
|
public function repairOrders(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(RepairOrder::class)
|
|
->withPivot('quantity_used', 'unit_cost')
|
|
->withTimestamps();
|
|
}
|
|
}
|