jeudi 2 novembre 2017

Allow only one set of data from foreach loop in Laravel-5.4 controller

How to allow only one set of data from an array in Laravel-5.4 controller:

foreach(Cart::content() as $cartitem) {
   if($cartitem->id === $id){
      do something....
   }
}

I want to take only the set of data from $cartitem when $cartitem->id === $id ($id is coming from request) and reject all other set of data from $cartitem. Set of data can be found anywhere (in any index) from the array.



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

Aucun commentaire:

Enregistrer un commentaire