jeudi 3 novembre 2022

Remove/unset specific row from collection in Laravel

I have this eloquent query

 $result= Result::query()
            ->where('city_id', '=', $search_city)
            ->get();
        } 

then inside loop

 foreach($result as $row)
                {
                    if(isset($row->user_id) && $row->user_id!=0)
                    {
                        $UserDetails = User::where('id',$row->user_id)->first();
                        if($UserDetails) 
                        {
                            if($UserDetails->type=='normal user')
                            {
                              // remove this specific row from result 
                            }
                
                        }
                    } 
                }

inside if condition if specific condition met i want to remove only that particular row from the result.

 return view('index', compact('result'));

Any solution Thanks



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

Aucun commentaire:

Enregistrer un commentaire