Skip to content

Commit

Permalink
Created the register store function for a new user --
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 13, 2024
1 parent 1f0d8c0 commit 1eed764
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,25 @@ public function store(Request $request): RedirectResponse
$request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
'phone' => ['required', 'string', 'max:255','min:8', 'unique:'.User::class],
'location' => ['required', 'string', 'max:255', 'min:3'],
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);

$user = User::create([
'name' => $request->name,
'email' => $request->email,
'phone' => $request->phone,
'location' => $request->location,
'password' => Hash::make($request->password),
]);

event(new Registered($user));

Auth::login($user);

// Send notification to user and admin

return redirect(route('dashboard', absolute: false));
}
}
2 changes: 1 addition & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class User extends Authenticatable implements MustVerifyEmail
protected $fillable = [
'name',
'email',
'role',
'role',// ['writer', 'client', 'admin']
'phone',
'location',
'profile_photo',
Expand Down
14 changes: 14 additions & 0 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@
<x-input-error :messages="$errors->get('name')" class="mt-2" />
</div>

<!-- Phone Number -->
<div class="mt-4">
<x-input-label for="phone" :value="__('Phone Number')" />
<x-text-input id="phone" class="block mt-1 w-full" type="text" name="phone" :value="old('phone')" required autocomplete="phone" />
<x-input-error :messages="$errors->get('phone')" class="mt-2" />
</div>

<!-- Location -->
<div class="mt-4">
<x-input-label for="location" :value="__('Location')" />
<x-text-input id="location" class="block mt-1 w-full" type="text" name="location" :value="old('location')" required autocomplete="location" />
<x-input-error :messages="$errors->get('location')" class="mt-2" />
</div>

<!-- Email Address -->
<div class="mt-4">
<x-input-label for="email" :value="__('Email')" />
Expand Down

0 comments on commit 1eed764

Please sign in to comment.