0

my code is

 @foreach($top_15_posts as $status )
       {!!  view('layouts.app-internal.user_status',[
       'status'=>$status,
       'user'=>\App\Eloquent\User::find($status->users_id)
            ]) !!}}
 @endforeach

How to overcome this error?

  • Possible duplicate of [Laravel Error: Method Illuminate\View\View::\_\_toString() must not throw an exception](http://stackoverflow.com/questions/26534016/laravel-error-method-illuminate-view-view-tostring-must-not-throw-an-excep) – Mārtiņš Briedis Jun 20 '16 at 14:43

1 Answers1

0

You might want to check this out. Laravel Error: Method Illuminate\View\View::__toString() must not throw an exception

There is a very simple solution: don't cast View object to a string.

Don't: echo View::make('..'); or echo view('..');

Do: echo View::make('..')->render(); or echo view('..')->render();

By casting view, it uses __toString() method automatically, which cannot throw an exception. If you call render() manually, exceptions are handled normally.

This actually is a PHP limitation, not Laravels. Read more about this "feature" here: https://bugs.php.net/bug.php?id=53648

-----------AND THIS---------------

Situation 1: Trying to print out a value in an array.

Answer 1: Try printing out the array. Are you sure it's an array? I've gotten this error when it was an object instead of an array. Try doing a print_r and seeing what you get.

Situation 2: You have this associated array like this:

Community
  • 1
  • 1
Dlaugh14
  • 313
  • 1
  • 5
  • 16