Here is my Database structure:
Also - there is a table users and reciever_id references that table id. I use that query to get count of each type of notifications as well as data for that type of notifications from notification_types table.
Notification:: select('notification_types.*', DB::raw('count(*) as total')) ->join('notification_types', 'notifications.type_id', '=', 'notification_types.id') ->groupBy('notifications.type_id') ->get()
What I need - is to set constraint on reciever_id, I just don't get - where should I put the where clause?