I am trying to achieve something like this:
I am using Laravel, and for example to display the results I would do a foreach on the array and display the title, the body etc. Example
@foreach($resArray as $res)
{{$res->Title}}
@endforeach
And that will display the title of each result in the array, I also have the date in $res->startDate
but I am not sure how to list each result with same date under their specific date.
You probably didn't understood..
So for example if I have two notifications from 10/07/2017
and one from 11/07/2017
they will display as this:
10/07/2017
- notification 1
- notification 2
11/07/2017
- notification
I was thinking at an if statement but what statement
if($res->startDate)
what so this won't work either, I was thinking to store them in arrays, for example array of date 11/07/2017
and display those arrays but would that even work...
Couldn't find too much from google as I am not too sure how to google this in a good maneer.
EDIT 1
I tried doing this:
$notifResult = notifications::where('userID', '=', $userID)->select('*')->groupBy(['date'])->get();
dd($notifResult);
but it didn't work, first of all, I had 3 results in database, it only got 2 of them and it didn't even group them by date, the two results that are listed before are from different days...
EDIT 2
I added toArray to it and this is what I've got:
still, it only picks two results...