samedi 14 septembre 2019

Invalid argument supplied for foreach() on laravel

I have like error message : Invalid argument supplied for foreach()

For my method index() I have this:

public function index(Request $request)
    {   
    if(\Auth::user()->hasRole('admin')){
         if($request->has('search'))
              $remarks = Remark::orderBy('instruction', 'asc')->where('instruction','like','%'.$request->input('search').'%');
         else
             $remarks = Remark::all();
    }else{
         \Auth::user()->load('remarks');
         $remarks = \Auth::user()->remarks;
    }

    return view('admin.remarks.index', compact('remarks'));
    }

Concerning my index.blade.php I have my loop "for" which is like this:

                <th>Instruction</th>
                <th>Description</th>
                <th>Date seance</th>
                <th>Name Candidate</th>
                <th>Email</th>
                </tr>
                </thead>
               @foreach($remarks as $remark)
                <tr>
                   <td> </td>
                   <td> </td>
                   <td> </td>
                   <td> </td>
                   <td> </td>
                   <td>

Do you have an idea of my problem please? I don't understand ??



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2USo7CV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire