I am trying to make function where counts the number of activity per site which has occurred and then when I am counting it , I want it to only give number of activity against each site id, so for example if there are two sites, site 1, site 2, site 1 activity 2, site 2 activity 0, I want it to count number of activity by sitename_id as in both the relation between sitename_id is same throughout so I was trying to match sitename_id within the same table with sitename_id but I guess that didn't work so I tried to match it with other table to just let it recognise with sitename_id from particular table
$activities=activitiesoccured::where('sitename_id', '=', monitoring::orderBy('sitename_id')->get())->count();