I have a table activites
in that table it have columns id, name, description, type, user_id, created_at, updated_at
from that i want to group by user_id and type
and created_at
want to be unique. How can i do it in laravel?
For this i did little bit of search but i didn't find any solution for this. To get unique column value some places mentioned like
$q = DB::table('activities')->distinct()->get(['created_at']);
here my question is how to get other column value?
without unique filter my current query look like
$q = DB::table('activities')
->select(DB::raw('user_id, type, count(*) as total'))
->whereNotNull('user_id');
->groupBy('user_id', 'type')
->get();