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,NULL,name,{$name}"], ['unique' => '数据已存在'])
->updateRules(['required', "unique:cars,a_id,{$id},id,name,{$name}"], ['unique' => '数据已存在']);

 

 

posted @ 2019-07-08 12:35  Wen1109  阅读(243)  评论(0编辑  收藏  举报