1

I am trying to use Pagination functionality provided by Laravel. Functionality works correctly for 1st page. However, pagination is not working for subsequent pages.

It is raising an error "Array to String Conversion" while echoing $tableData. Below is my code snippet of view.

<tbody>
  @foreach ($tableData as $d)
   <tr>
    <td></td>
    <td>{{$d->ItemMake}}</td>
    <td>{{$d->Item}}</td>
    <td>{{$d->style}}</td>
    <td>{{$d->Price}}</td>
    <td>{{$d->ItemValue}}</td>
  </tr>
 @endforeach
  <tr>
   <td>
    <?php       
        echo $tableData;
     ?>
   </td>
  </tr>
 </tbody>

while using "{{$tableData}}" , its throwing the error, Error : "htmlentities() expects parameter 1 to be string, array given"

while using "{!! $tableData !!}" , its throwing the error, Error : Array to string conversion

2
  • Where's your pagination code? Commented Sep 20, 2016 at 14:40
  • If $tableData is a Query builder with Pagination applied($query->paginate(10)) then you can use render method to draw pagination like this {!! $tableData->render() !!} and the error is not because of Pagination, it's because you are trying to print an Array with Blade Engine. Commented Sep 20, 2016 at 15:38

2 Answers 2

1

The problem is not in pagination.

You can't echo array like string with {!! $tableData !!} or {{ $tableData }} or echo $tableData;

To display contents of an array you should use foreach loop or $tableData[0] to display first element of that array, for example. Also you can use var_dump() or dd() functions if you just want to look what's inside of an array.

Sign up to request clarification or add additional context in comments.

Comments

0

I think that you want to echo pagination links for next pages.

Change

echo $tableData;

to

{{ $tableData->links }}

and read manual.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.