mardi 26 mai 2020

Assigning user role issue in laravel

In my laravel application, I have a registration function to register users. following is my current user create function in the RegisterController

protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'last_name' => $data['last_name'],
            'email' => $data['email'],
            'mobile'=>$data['mobile'],
            'username'=>$data['username'],
            'password' => Hash::make($data['password']),
            'propic'=>'user-pic.png',
            'user_roles' =>'customer',
        ]);
    }

When I execute the code customer registration works properly.

But now I want to assign an user role (customer) to this user when registering, How can I modify above method to assign the user role?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire