Я хочу, чтобы максимально 3 уведомления конкретного пользователя, непрочитано, а также дата их create_at
ниже или равна определенной дате, я хочу что-то вроде сильфона запроса:Как написать этот запрос в laravel?
select count(*) as aggregate from
(
select * from `notifications`
where `notifications`.`user_id` = '20' and `notifications`.`user_id` is not null and `is_read` = '0'
and created_at <= '2015-07-12 11:41:10' limit 3
) AS src
просто мольбы рассмотреть сильфона запрос:
$displayedNotifications = $user->notifications(function($query) use ($timestamps) {
return $query->Where('created_at', '<=', $timestamps);
})->unread()->take(3)->count();