Level 70
@birdietorerik I believe created_at is a timestamp that contains YYYY-MM-DD HH:MM:SS.
In that case, you can use whereDate() like that:
return $user->unreadNotifications->whereDate('created_at', '2023-07-05');
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi!
Have this function that are working 100%
public function NotificationsFlow()
{
$user = auth()->user();
return $user->unreadNotifications;
}
But only want to return unreadnotifications from date today Like:
public function NotificationsFlow()
{
$user = auth()->user();
return $user->unreadNotifications->where('created_at'==='2023-07-05');
}
But this dosent work, i have 2 record with date 2023-07-05
How do i do this ?
@birdietorerik How about this?
public function NotificationsFlow()
{
$user = auth()->user();
$today = now()->toDateString();
return $user->unreadNotifications->where('created_at', '>=', $today);
}
Please or to participate in this conversation.