staudenmeir / belongs-to-through

Laravel Eloquent BelongsToThrough relationships
MIT License
1.15k stars 88 forks source link

Cant change trough class id #82

Closed arturasfrontit closed 1 year ago

arturasfrontit commented 1 year ago

where is no way to change e_order_id

selecte_orders.* frome_ordersinner joine_order_itemsone_order_items.e_order_id=e_orders.idwheree_order_items.idis null limit 1

    public function order()
    {
        return $this->belongsToThrough(Order::class, OrderItem::class, 'invoice_id', null, [OrderItem::class=> 'order_id']);
    }
staudenmeir commented 1 year ago

Hi @arturasfrontit, Try this instead:

public function order()
{
    return $this->belongsToThrough(Order::class, OrderItem::class, 'invoice_id', null, [Order::class=> 'order_id']);
}                                                                                       ^^^^^
arturasfrontit commented 1 year ago

Hi @arturasfrontit, Try this instead:

public function order()
{
    return $this->belongsToThrough(Order::class, OrderItem::class, 'invoice_id', null, [Order::class=> 'order_id']);
}                                                                                       ^^^^^

Tried this one, but it didin't work for me

staudenmeir commented 1 year ago

What isn't working? Is there an error? What does the executed SQL look like?