0
votes

I have a form fields in the view as:-

<input type="email" name="user[email]">
<input type="text" name="name">
<input type="text" name="designation">

While submitting this post request, I have a rule defined as:-

app\Http\Requests\StaffEditRequest.php

$rule['user.email'] = 'email|unique:users';

However, when laravel tries it to validate the request it queries the database as if there is a field name "user.email" in the users table. How to customize the field name so that I can tell laravel that I am looking for email field in the users table and not user.email?

1

1 Answers

1
votes

You need to define the column in in unique parameter. Do like following:

$rule['user.email'] = 'email|unique:users,email';

Ref: Laravel Doc