0

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 to validate the request it queries the database as if there is a field name user.email in the users table.

How do I 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 Answer 1

1

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

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

Ref: Laravel Doc

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.