How to add foreach to Request $request in Controller
P粉803527801
P粉803527801 2024-03-28 11:18:16
0
1
343

I have a post route and I want to add a foreach loop to the request like this:

public function updateProductAttrsInfo(Request $request, $id)
    {
        foreach($request as $req){
            dd($req);
        }
    }

But this is wrong because $request is an object and not an array, so foreach cannot be applied to it.

So I'm wondering how to properly apply foreach to this $request?

P粉803527801
P粉803527801

reply all(1)
P粉488464731

You can try this:

foreach($request->all() as $k => $v){}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template