Skip to content
Advertisement

Register after admin auth in laravel 7

I want to have the registration after the auth, so the admin could create a user.I tried to find something about that but all examples are in Laravel 5s and the methodes of the controllers aren’t the same. Have you an idea,please?

enter image description here

Advertisement

Answer

If you want to create a new user as an admin, you just have to use the User::create([ ... ]) method. Remeber to put an email and a hashed password, such that the user can log in.

Example for user creation:

User::create([
  'email' => 'foo@bar.com',
  'password' => bcrypt('foobar'),
]);

If you want to remove the registration for guests, you should remove the RegistrationController and change the route to Auth::routes(['register' => false]);.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement