ruchit288's avatar

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

  1. users :- id,user_name
  2. user_pages :- id,page_name
  3. user_pages_content:- id, user_id, user_page_id, content

Relationship

  1. user_pages have one-to-many relationship with user_pages_content
  2. 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

0 likes
0 replies

Please or to participate in this conversation.