<?php

namespace App\Models\Shop;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;

class CustomerSaleChannel extends Model
{
    use SoftDeletes, Userstamps;

    protected $guarded = ['id'];

    protected $table = 'shop_customer_sale_channels';

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function sale_channel()
    {
        return $this->belongsTo(SaleChannel::class);
    }

    public function scopeByCustomer($query, $customerId)
    {
        return $query->where($this->table.'.customer_id', $customerId);
    }

    public function scopeBySaleChannel($query, $saleChannelId)
    {
        return $query->where($this->table.'.sale_channel_id', $saleChannelId);
    }
}
