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".
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!
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();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community