Files
boursecu_server/app/Models/CustomerSpecialPricePackage.php
2026-08-16 22:00:23 +03:30

52 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class CustomerSpecialPricePackage extends Model
{
protected $table = 'customer_special_price_packages';
protected $fillable = [
'title',
'profit_buy',
'profit_sell',
'show_product',
'is_active',
];
protected $casts = [
'profit_buy' => 'integer',
'profit_sell' => 'integer',
'show_product' => 'boolean',
'is_active' => 'boolean',
];
public function customers(): BelongsToMany
{
return $this->belongsToMany(
Customer::class,
'customer_special_price_package_customer',
'package_id',
'customer_id'
)->withPivot([]);
}
public function products(): BelongsToMany
{
return $this->belongsToMany(
Product::class,
'customer_special_price_package_product',
'package_id',
'product_id'
)->withPivot([]);
}
public function scopeActive($query)
{
return $query->where('is_active', true);
}
}