Support the ongoing development of Laravel.io →
Requests Database
Last updated 1 year ago.
0

I believe there is a Lauracast on something very similar to this.

0

You should make category its own model, and define a belongsTo/hasMany relation between Article and Category models. Then your line will looks like this:

$articles = Category::find($category)->articles;

Going through the whole Laravel 5 Fundamentals series will help greatly with understanding "the Laravel way".

Last updated 8 years ago.
0

Yes, but I thought there is a dirtier way, a way around that that could just be used for this example of mine. Oh well, thank you for clearing it up for me!

0
Solution

There is a dirtier way. You actually almost got it. You missed ->get() call to actually fetch the data from table.

$articles = DB::table('articles')->where('category', $category)->get();
0

I think I love you. Thank you very much, it works!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

lnenad lnenad Joined 25 Apr 2015

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.