phplaravellaravel-9userid

User Management / Get iduser


I'm creating a user management where you can change a user's role, USER or ADMIN.

I'm a beginner in Laravel 9, and I would like to know how can I get the iduser when I click on the user's button ? For example this is a user profile. The button can change his role form user to admin but I can't get his id...

I tried this but it's written 0 instead of 2 (his iduser)

        $userID = User::find('iduser');
        dd($userID);

Thank you very much!

Edit : When I click on a user profile, I want to get HIS/HER id, not mine or logged user :)

FOR EXAMPLE :

This user, I click on "Changer en administrateur" (change to admin), I just want his id ;)

enter image description here


Solution

  • $request->validate([
                'type' => 'required',
            ]);
        
            DB::table('users')
                ->where('iduser', $request->iduser)
                ->update(
                    ['type' => $request->type]
                );
    

    This one works to select a user's id :)