I'm trying to return data with a pagination. When I'm returning the data as paginate() I receive an error: htmlspecialchars() expects parameter 1 to be string, array given
My controller:
$tickets = Ticket::where('company_id', Auth::user()->company_id)->paginate(3);
Blade:
<table >
<tr>
<th></th>
<th >Updated at</th>
<th >Case Title</th>
<th >Manager</th>
<th >Case ID</th>
<th >Remaining</th>
<th >Status</th>
</tr>
@foreach($tickets as $ticket)
<tr >
<td ><span >
@if($ticket->isNew($ticket->created_at))
New
@endif
</span></td>
<td >{{ $ticket->updated_at }}</td>
<td >{{ $ticket->title }}</td>
<td >{{ $ticket->getAdmin->first_name }} {{ $ticket->getAdmin->last_name }}</td>
<td >{{ $ticket->id }}</td>
<td >
@php
$dueDate = \Carbon\Carbon::parse($ticket->end_date);
@endphp
@if($dueDate->isPast())
<span >Overdue</span>
@else
{{ $ticket->remaining_date() }} Days
@endif
</td>
<td >
@if($ticket->status == 1)
<span >Active</span>
@endif
@if($ticket->status == 2)
<span >Closed</span>
@endif
@if($ticket->status == 3)
<span >Late</span>
@endif
</td>
</td>
</tr>
@endforeach
</table>
{{!! $tickets->links() !!}}
I don't get it why I receive the error and have tried to Google around it. Why is the error appear and what's the solution?
CodePudding user response:
Update your version of Laravel. This was a breaking bug for 8.78. They tried changing Pagination Navigation for screen readers, but it broke certain translation settings, so it was reverted back. The details are at https://github.com/laravel/framework/pull/39928
@taylorotwell @xanderificnl This actually introduces a bug that breaks Tailwind pagination out of the box, and it should ideally be reverted.
When attempting to use Tailwind pagination, I'm seeing the following:
htmlspecialchars(): Argument #1 ($string) must be of type string, array given (View: /var/www/html/vendor/laravel/framework/src/Illuminate/Pagination/resources/views/tailwind.blade.php)The line causing the issue:
<nav role="navigation" aria-label="{{ __('Pagination') }}" >This is due to Laravel shipping with a
resources/lang/en/pagination.phpfile by default. This PR causes the array returned by the pagination language file to be passed into the__()method, which results in the parsing exception.
