我收到與閱讀通知的分頁有關的錯誤。謝謝您的幫助。這是我的控制器代碼,它在運行時會出現此錯誤
public function NotificationsRead(User $user)
{
$no = Auth::user()->readNotifications()->paginate(7)->latest()->get();
return view('user-profile.notifications-read', compact('user', 'no'));
}
當我洗掉 latest() 時,他給 get() 一個錯誤,我不知道如何分頁。和 A 有兩種型別的通知
uj5u.com熱心網友回復:
你應該做
$no = Auth::user()->readNotifications()->latest()->paginate(7);
通過這種方式,您可以在分頁之前按降序排序。您的代碼對分頁創建的結果集合進行排序。
https://laravel.com/docs/8.x/queries#latest-oldest
uj5u.com熱心網友回復:
@jack 這是我的刀片
<div class="card-header text-black text-bold">
????? ??
</div>
<div class="card-body">
<blockquote class="blockquote mb-0">
<div class="card">
<div class="card-body">
<h5 class="card-title">?????:</h5>
@foreach(auth()->user()->readnotifications->where('type','App\Notifications\NewReplySubmittedRoyal') as $notification)
<p class="card-text"><a
href="{{$notification->data['UserProfile']}}">{{$notification->data['name']}}</a>
?? ???? ???? ???? ??? ?? ??????:
{{$notification->data['thread_title']}}
?? {{$notification->data['time']}}<br>??? ???.
</p>
<form>
<button type="submit" hljs-number">2 ml-2"><a
href="{{$notification->data['route']}}">???? ????</a></button>
</form>
<hr>
@endforeach
{{--*********** ??? ??? ??????????--}}
@foreach (auth()->user()->readNotifications->where('type','App\Notifications\FollowerNotifications') as $notification)
<p hljs-string">">{{$notification->data['name']}} ?? ???? ?? ??????:
{{$notification->data['thread_title']}}
????? ???.
</p>
<a href="{{$notification->data['route']}}">???? ????</a>
<hr>
@endforeach
{{$no->render()}}
我有兩種型別的通知
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/407110.html
標籤:
