Closed davecardwell closed 3 years ago
The Travis CI build is failing due to reasons unrelated to this pull request (cc @sarthaksavvy)
Amazing, thanku for this contribution
you can just do it with using Rule class:
use Illuminate\Validation\Rule;
'required|'.Rule::unique('admins','email')->ignore(request('admin.id')),
When creating a new admin the value of
request('admin.id')
isNULL
, which means the email validation rule becomes"required|email|max:255|unique:admins,email,"
.This results in the SQL
select count(*) as aggregate from "admins" where "email" = 'test@example.com' and "id" <> ''
, which causes an exception in PostgreSQL:SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bigint: ""
.This change first checks that
request('admin.id')
is notNULL
before adding it to the email uniqueness check.Fixes #86 and fixes #114