From 3e16cee24ff33c6e9b6ef43b80fc2ae4302e2f55 Mon Sep 17 00:00:00 2001 From: Hasin Hayder Date: Sat, 25 Jun 2022 16:29:35 +0600 Subject: [PATCH] Default Role Slug Fix for New Users --- app/Http/Controllers/UserController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9281aae..0b25cc9 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -44,12 +44,8 @@ class UserController extends Controller { 'name' => $creds['name'] ]); - $user->roles()->attach(Role::firstOrCreate([ - 'slug' => config('hydra.default_user_role_slug', 'user') - ],[ - 'name' => Str::title(config('hydra.default_user_role_slug', 'user')) - ])); - + $defaultRoleSlug = config('hydra.default_user_role_slug', 'user'); + $user->roles()->attach(Role::where('slug', $defaultRoleSlug)->first()); return $user; }