I have a simply query like this:
$events = EventHistory::where('u_h_id', $id)
->where('has_read', 0)
->get(['event_type']);
This will return a result that looks like this:
[
{
event_type: 1
},
{
event_type: 2
},
{
event_type: 2
},
{
event_type: 4
},
{
event_type: 6
},
{
event_type: 1
},
{
event_type: 3
},
{
event_type: 1
},
{
event_type: 4
},
{
event_type: 1
},
{
event_type: 4
},
{
event_type: 4
}]
But now I need a way to count the specific values so I can return now many results exist in the different event types
eg, on the result above I want to return
$type1 = 4;
$type2 = 2;
$type3 = 1;
$type4 = 4;
$type6 = 1;
There are 4 results that has a event_type value of 1 etc..