Laravel 5. How to grab posts by category and not by type -


on project i'm dealing there 3 main components type, category , post.

example: have 3 types (news, photo, video) each type has own categories. news has 3 categories news1, news2, new3 , each of them has own posts.

now can access type mydomain.com/news , of course receive post (not separated on categories)

i want show posts category, when access mydomain.com/news foreach categories , below them associated posts.

$categories = categories::bytype($t)->get();  $lastitems = posts::select('posts.*')         ->leftjoin('categories', function($leftjoin){             $leftjoin->on('categories.id', '=', 'posts.category_id');         })         ->approve('yes')         ->latest("published_at")         ->get(); 

so have on controller, separated categories on each category show posts associated news type , not categories.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -