Support the ongoing development of Laravel.io →
Database Views Blade
Last updated 2 years ago.
0
Solution

Looks good to me.

Only this:

$item->mybrands = Outfit::find($id)->brands->lists('name');            
$item->mystyles = Outfit::find($id)->styles->lists('name');
$item->mystores = Outfit::find($id)->stores->lists('name');

You should store Outfit::find($id) in a variable. If you want, you can also use "with".

Greetings.

Last updated 2 years ago.
0

Thank you @Ruk33 for your answer. I thought Laravel itself had some special method to deal with this. I'm happy I found the right solution from the start.

Last updated 2 years ago.
0

Great question, elaborated very well! I also find myself often in the situation where I'm not sure how to pass data to the view. Further opinions are appreciated!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.