Forums

Pivot tables in CCv5

admin_wiky 14 Mar, 2018
Hello,
I cant figure out to correctly set pivot tables.
table1 contains list of my friends (friend_id, name)
table2 contains list of loans of friends (id,friend_id, year, loan)

and I need to show table with columns: friend_id, loan2015, loan2016, loan2017,loan2018
so I have created 4 models: friends, loan2015, loan2016, loan2017,loan2018 and set relation type to belongsTo for each model.

in years 2015-2018 I have about 20records for each year and frind, in year 2018 I have only 4 records.
when I take a look for result I see in the list only 4 records (rows) corrensponding 4 records in 2018 (all years in colum are filled with loan values) but I need to show list of all friends.

So I did try set type of relation to HasMany, then it shows list of all my friends, but without values in years columns and dont know why.

can you help what I am doing wrong?

thank you
This topic is locked and no more replies can be posted.