Apr 13, 2015
0
Level 1
Groupby with eloquent
Hello I am working on one e-commerce portal in that i am stuck in CMS static pages module. Below are the tables structure which i am using CMS static pages
- users :- id,user_name
- user_pages :- id,page_name
- user_pages_content:- id, user_id, user_page_id, content
Relationship
- user_pages have one-to-many relationship with user_pages_content
- users have one-to-many relationship with user_pages_content
Now i want record sof all users with latest content, according to the selection of user_page (e.i page name).
below are the query which i have used currentl
$userPageContent = UserPageContent::sortable(); $userPageContent = $userPageContent->whereRaw('user_pages_content.user_page_id=" '.$id.' " GROUP BY user_pages_content.user_id DESC) ->with(users,userPage) ->orderBy('user_pages_content.updated_at','desc')
but i didn't get the exact result which i want
Please help me on this
Thanks and regards Ruchit Patel
Please or to participate in this conversation.