dimanche 30 juillet 2017

How to pass model data inside foreach loop to views using laravel5

I have a foreach loop where each time certain value is matched and then it related records is fetched

 foreach($results as $result){
    // Value may be 1,2,3 etc
    if($result->id == $value){
       $users = User::whereId($value)->get();
    }
  }
  return view('winners.winners',compact('users'));

Now how to pass all users records to the view? Currently it only fetches the first record!



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

Aucun commentaire:

Enregistrer un commentaire