krstic200329444
krstic200329444

Hi,

I'm using relation manager for belongsToMany relation between "reservations" and "addons" (reservation can have many addons).

And there is a very weird problem. I've included 3rd column called quantity in pivot table - http://take.ms/oFK1i

But when I want to display pivot data, it shows only 2 (reservation_id and addon_id) - http://take.ms/eOMqD

To be even more tricky, quantity update works (when I enter value in this form it update quantity column for specific correct reservation_id and addon_id) - http://take.ms/YMhXB

Code

config_relation.yaml


addon:

label: Addons

    view: 
        list: $/luxor/ride/models/addon/columnsPivot.yaml

       toolbarButtons: add|remove|create

    manage:
        form: $/luxor/ride/models/addon/fields.yaml

        showCheckboxex: true

    pivot:
        form: $/luxor/ride/models/addon/fieldsPivot.yaml

columnsPivot.yaml


columns: 

    name: 
        label: Addon 

        type: text 

    cost: 
        label: Cost 

        type: number 

    pivot:  // It should be pivot[quantity], but I set pivot just to see which fields are available, and quantity missing 
        label: Quantity 

        type: number 

fieldsPivot.yaml


fields:

  pivot[quantity]:

        label: QT

Reservation model (relation part)


    public $belongsToMany = [
        'addon' => 'Luxor\Ride\Models\Addon',
        'table' => 'addon_reservation',
        'order' => 'name',
        'pivot' => ['reservation_id', 'addon_id', 'quantity']
    ];    


Did somebody run on similar issue?

Thanks

Last updated

krstic200329444
krstic200329444

I found a workaround for this. In columnsPivot.yaml, instead of using pivot[quantity]


    pivot[quantity]: 
        label: Quantity 
        type: number 

I set regular column with select from pivot table


    quantity: 
        label: Quantity 
        type: number 
        select: addon_reservation.quantity

st.james.jomuad13119
st.james.jomuad13119

Solve it!

public $belongsToMany = [ 'task' => [ \Bookrr\Keeprr\Models\Task::class, 'table' => 'bookrr_keeprr_worktask_pivot', 'key' => 'work_id', 'pivot' => ['status', 'priority','note'] ] ];

Last updated

1-3 of 3