35 lines
837 B
PHP
35 lines
837 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
#[Fillable(['name', 'description', 'status'])]
|
|
class Product extends Model
|
|
{
|
|
public function customers(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Customer::class, 'customer_product')
|
|
->withPivot('purchase_date')
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function contracts(): HasMany
|
|
{
|
|
return $this->hasMany(Contract::class);
|
|
}
|
|
|
|
public function handovers(): HasMany
|
|
{
|
|
return $this->hasMany(Handover::class);
|
|
}
|
|
|
|
public function productServices(): HasMany
|
|
{
|
|
return $this->hasMany(ProductService::class);
|
|
}
|
|
}
|