Ad

Invalid Argument Supplied For Foreach() (View: /home/anis/OrangeFormation/resources/views/admin.blade.php)

- 1 answer

can anyone help??

this is my controller method:

 public function index()
{
    $formations = Formation::latest()->paginate(5);
    return view('formation', compact('formations'))
        ->with('i', (request()->input('page', 1) - 1) * 5);
}

and my blade is: my blade code is here

Ad

Answer

foreach ($variables as $variable)

Here $variables is something iterable. In your example, it's an empty string if the $variables is null. So you got the error. $variables can not be an empty string. In your blade you should only do the foreach if the $variables is not null

Ad
source: stackoverflow.com
Ad