Skip to content

Commit

Permalink
Update users nickname
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchanhyung98 committed Apr 2, 2024
1 parent d20fb58 commit c71adba
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions app/Http/Controllers/Account/SignUpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ class SignUpController extends Controller
*/
public function __invoke(SignUpRequest $request)
{
DB::beginTransaction();
try {
DB::beginTransaction();
$user = User::firstOrCreate([
'email' => $request->email,
], [
'name' => $request->name,
'nickname' => $request->nickname ?? $request->name,
'nickname' => $request->nickname,
'password' => Hash::make($request->password),
]);

if (! $user->wasRecentlyCreated) {
abort(409, 'already exists');
}
// $user->sendEmailVerificationNotification();

DB::commit();
} catch (Exception $e) {
DB::rollBack();
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/Account/SignUpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function rules(): array
return [
'email' => ['required', 'email', 'unique:users,email', 'max:100'],
'name' => ['required', 'string', 'max:50'],
'nickname' => ['nullable', 'string', 'max:50'],
'nickname' => ['required', 'string', 'unique:users,nickname', 'max:50'],
'password' => ['required', 'string', 'min:8', 'max:100'],
];
}
Expand Down
1 change: 1 addition & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class User extends Authenticatable
*/
protected $fillable = [
'name',
'nickname',
'email',
'password',
];
Expand Down

0 comments on commit c71adba

Please sign in to comment.