Я новичок в laravel и хочу показать все вчерашние предыдущие сообщения в разделе «Ранее» из нового раздела, как я могу это сделать? пожалуйста, помогите мне спасибо.
Контроллер
public function index(){
$userNotificationIds = UserNotification::where('user_id',Auth::user()->id)->pluck('notification_id');
$data=[
'userNotification' => Notification::whereIn('id',$userNotificationIds)->orderBy('created_at','DESC')->paginate(8),
];
return view('web.user_notification',$data);
}
HTML-просмотр
<h4 class="fw-bold mb-3">New</h4>
@if(count($userNotification) > 0)
@foreach ($userNotification as $value)
<div class="row notification rounded ">
<div class="d-flex pt-3">
<img class="rounded-circle" width="32px" height="32px" src="{{url('')}}/assets/web/img/profile-pic.png" alt="">
<div class="notification-text ms-3">
<span class="username fw-bold">Toby Ng</span>
<i class='bx bxs-circle small mx-2'></i>
<span class="text-muted">{{ $value->created_at->diffForHumans() }}</span>
<p class="mt-2"><span id="dots"> </span> {!! $value->description !!}</p>
<span class="text-primary fw-bold cursor-pointer" onclick="myFunction()" id="myBtn">Read more</span>
</div>
</div>
</div>
@endforeach
@endif
{{ $userNotification->links() }}
<h4 class="fw-bold">Earlier</h4>
<div class="row notification rounded">
<div class="d-flex pt-3">
<img class="rounded-circle" width="32px" height="32px" src="img/avatar.png" alt="">
<div class="notification-text ms-3">
<span class="username fw-bold">Steven McNam</span>
<i class='bx bxs-circle small mx-2'></i>
<span class="text-muted">Yesterday</span>
<p class="mt-2">Welcome to WFH! Here is the link for you to get started. Please take your time to read it. <a href="#">https://www.google.com/</a></p>
</div>
</div>
</div>
вы можете запросить created_at меньше или равно вчерашнему дню
$earlier = Notification::whereIn('id',$userNotificationIds)->whereDate('created_at', '<=', \Illuminate\Support\Carbon::yesterday())->orderBy('created_at','DESC')->paginate(8)