hasMany(CustomerSaleChannel::class); } public function customers() { return $this->belongsToMany(Customer::class, CustomerSaleChannel::class)->wherePivotNull('deleted_at'); } public function deliveries() { return $this->hasMany(Delivery::class); } public function price_lists() { return $this->hasMany(PriceList::class); } public function tariffs() { return $this->hasManyThrough(Tariff::class, PriceList::class, 'sale_channel_id', 'id', 'id', 'tariff_id'); } public function scopeByCode($query, $code) { return $query->where($this->table.'.code', $code); } public function scopeById($query, $id) { return $query->where($this->table.'.id', $id); } }