37 lines
784 B
PHP
37 lines
784 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class PriceList extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'valid_from',
|
|
'valid_to',
|
|
'is_default',
|
|
];
|
|
|
|
protected $casts = [
|
|
'valid_from' => 'date',
|
|
'valid_to' => 'date',
|
|
'is_default' => 'boolean',
|
|
];
|
|
|
|
public function clientGroups(): HasMany
|
|
{
|
|
return $this->hasMany(ClientGroup::class, 'price_list_id');
|
|
}
|
|
|
|
public function products(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Product::class, 'product_price_list')
|
|
->withPivot('price')
|
|
->withTimestamps();
|
|
}
|
|
}
|
|
|