Reputation: 27185
In laravel 5.4, how we can write the following:
<li class="page-item {{ ($paginator->onFirstPage() ? 'disabled' : '') }}">
Above is not working, and it shows output as
<li class="page-itemdisabled">
- If condition is true and
<li class="page-item ">
- If condition is false.
Notice an space after page-item
class. I don't want that.
To fix that, I simply tried:
<li class="page-item{{ ($paginator->onFirstPage() ? 'disabled' : '') }}">
But the above not working when condition is true and generates output as below:
<li class="page-itemdisabled">
Please advise how I can fix this, checked Laravel docs + Googled, but not finding anything such.
Upvotes: 0
Views: 410
Reputation: 21681
You should update your code like:
<li class="page-item {{isset($paginator->onFirstPage()) ? 'disabled' : ''}}">
Upvotes: 1
Reputation: 1103
Just add a space before disabled. Notice the added space below.
<li class="page-item{{ ($paginator->onFirstPage() ? ' disabled' : '') }}">
Upvotes: 2
Reputation: 869
Intead of 'disabled' use ' disabled':
<li class="page-item{{ ($paginator->onFirstPage() ? ' disabled' : '') }}">
Upvotes: 1
Reputation: 905
you can write
<li class="page-item{{ ($paginator->onFirstPage() ? 'disabled' : '') }}">
to
<li class="page-item{{ ($paginator->onFirstPage() ? ' disabled' : '') }}">
Upvotes: 1