Pagination - No Links Showing Evening All
I'm stuck on something thats so simple but just baffling me. I'm trying to paginate some records but the pagination links don't appear. I've done a dd($completeOrders) and i can see the orders & pages detail etc but just no links in the view.
Please could one of you kind folk advise where i might be going wrong or what i'm missing.
//Controller
$completeOrders = Order::where('stage', 'complete')->orderBy('completed_at', 'desc')->paginate(8);
//View
@forelse($completeOrders as $complete)
//Table
@endforelse
{{ $completeOrders->links() }}
Thank you in advance.
@forelse($completeOrders as $complete)
// table
{{ $completeOrders->links() }}
@empty
<p>No orders</p>
@endforelse
And of course if you don't have more that 8 orders in your database, the pagination links won't show.
Hey @michaloravec
Thanks for your response.
I've tried both in & out the forelse loop but still no joy in showing the links.. Also tried just a @foreach but no joy either.
{{ $completeOrders->links() }}
@empty
<tr>
<td colspan="11" class="strong">No orders found.</td>
</tr>
@endforelse
@oli_d111 When you try this, what do you get?
dd(Order::where('stage', 'complete')->count());
Move it outside of foreach, because you propably show it in the table.
<table>
@if ($completeOrders->isNotEmpty())
foreach ($completeOrders as $complete)
// tr
@endforeach
@else
<tr>
<td colspan="11" class="strong">No orders found.</td>
</tr>
@endif
</table>
{{ $completeOrders->links() }}
@michaloravec I've tried it inside and outside of the loop.
I also tried using the ```@if statement you recommended & still no joy.
Do you think the naming might be throwing it off having complete in both the variables at the start of the foreach?
If you put to the url ?page=2, ?page=3 etc do you get different result in the table?
@michaloravec I think you've just answered my question.
Because i have the orders on tabs Pending | Complete | Void i think the tabs are throwing it out.
I'll have to split onto separate pages. Thank you for your help. Much appreciated.
Please sign in or create an account to participate in this conversation.