Такой валидатор:
1 2 3 4 |
$rules = [ 'name' => 'required|string|unique:content_items,name,null,null,content_id,2', ]; return \Validator::make(['name' => 'test'], $rules); |
Сгенерирует запрос:
1 2 3 |
select count(*) as aggregate from "content_items" where "name" = 'test' and "content_id" = '2' |
Такой валидатор:
1 2 3 4 |
$rules = [ 'name' => 'required|string|unique:content_items,name,1,active,content_id,2', ]; return \Validator::make(['name' => 'test'], $rules); |
Сгенерирует запрос:
1 2 3 |
select count(*) as aggregate from "content_items" where "name" = 'test' and "active" <> '1' and "content_id" = '2' |
Такой валидатор:
1 2 3 4 |
$rules = [ 'name' => 'required|string|unique:content_items,name,1,active' ]; return \Validator::make(['name' => 'test'], $rules); |
Сгенерирует запрос:
1 2 3 |
select count(*) as aggregate from "content_items" where "name" = 'test' and "active" <> '1' |