Laravel-admin 表单提交同时验证俩个以上的字段唯一值

$name = isset(request()->all()['name']) ? request()->all()['name'] : '';
$id = isset(request()->route()->parameters['car']) ? request()->route()->parameters['car'] : '';
 
$form->select('a_id', 'a_id')->options('/admin/xx')
->creationRules(['required', "unique:cars,a_id,NULL,id,name,{$name}"], ['unique' => '数据已存在'])
->updateRules(['required', "unique:cars,a_id,{$id},id,name,{$name}"], ['unique' => '数据已存在']);

posted @ 2019-07-08 13:53  Wen1109  阅读(1765)  评论(0编辑  收藏  举报