Skip to content
Advertisement

calling relation with a parameter in the view

i know this has been asked alot , but none of the solution works for me as i want to use this in the view

i have 3 tables

JavaScript

so when i list the blogs in the view , for each blog i want to show what languages has been stores for this Blog

basically i want to do something like this

JavaScript

in the view

JavaScript

here is what im stuck

JavaScript

if i can have this relation in the Language model

JavaScript

of course this doesn’t work and gives me some weird object like

JavaScript

Advertisement

Answer

You just need to define a relation on you Blog model. As you already have pivot table for the following relationships

Blog belongsToMany Language(s)

Language belongsToMany Blog(s)

JavaScript

Then in blade view

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement