Browse Source

add unique validation for name and don't fail validation when already the owner of data

pull/260/head
Kode 6 years ago
parent
commit
12e109f82c
  1. 6
      app/Http/Controllers/UserController.php

6
app/Http/Controllers/UserController.php

@ -53,7 +53,7 @@ class UserController extends Controller
public function store(Request $request)
{
$validatedData = $request->validate([
'name' => 'required|max:255',
'name' => 'required|max:255|unique:users',
'email' => 'required|email|unique:users',
'password' => 'nullable|confirmed',
'password_confirmation' => 'nullable'
@ -119,8 +119,8 @@ class UserController extends Controller
public function update(Request $request, User $user)
{
$validatedData = $request->validate([
'name' => 'required|max:255',
'email' => 'required|email|unique:users',
'name' => 'required|max:255|unique:users,name,'.$user->id,
'email' => 'required|email|unique:users,email,'.$user->id,
'password' => 'nullable|confirmed',
'password_confirmation' => 'nullable'
]);

Loading…
Cancel
Save