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); } }