0

My validation fails with this:

$this->validate($request, [
            'name'           => ['required'],
            'email'          => ['required', 'email', 'unique:organisers',$organiser->id,'organisers_id'],
            'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000'],
        ]);

but it works with this:

$this->validate($request, [
            'name'           => ['required'],
            'email'          => ['required', 'email', 'unique:organisers'],
            'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000'],
        ]);

1 Answer 1

2

This:

'unique:organisers',$organiser->id,'organisers_id'

needs to be:

'unique:organisers,'.$organiser->id.',organisers_id'

or (note the double-quotes):

"unique:organisers,{$organiser->id},organisers_id"

The , means "new array element", the . means "add to this string".

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

2 Comments

This should be the right answer. Indeed, , will add a new element to the array, which is not what you want.
Didn't know you can change to this format. I was too focused on their given format that I didn't bother changing it. Thank you!

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.