Support the ongoing development of Laravel.io →
Database Eloquent Validation
Last updated 2 years ago.
0

Laravel 5.4 - Validation - Unique Rule

Laravel 5.2 - Validation - Unique Rule <- similar formatting to what you are using

its in the validation docs for the unique rule - "Forcing A Unique Rule To Ignore A Given ID"

0

Thanks for answer! If found that similar rule works ok when I need "=" in sql statement

required|unique:department,name,null,department_id,department_id,1

and I have sql :

select count(*) as aggregate from `jsn_department` where `name` = 'Department_111222' and `department_id` = '1'

But I failed to set condition with "!=" : Setting rule as :

required|unique:department,name,null,department_id,department_id!=,1

I got error:

Unknown column 'department_id!=' in 'where clause' (SQL: select count(*) as aggregate from `jsn_department` where `name` = Department_111222 and `department_id!=` = 1)

As I see "department_id!=" is wrapped with "`" char and "=" is set anyway...

Which is the right syntax ?

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.