laravel-admin form表单中,同时验证两个或多个唯一值

 

最近在使用laravel-admin,记录一下用laravel-admin时遇到的问题

一、form表单中,同时验证两个或多个唯一值

$name = isset(request()->all()['name']) ? request()->all()['name'] : '';

$form->select('aircraft_id', '机场名称')->options('/admin/data-aircraft')
->creationRules(['required', "unique:cars,aircraft_id,NULL,NULL,name,{$name}"]);

$form->select('aircraft_id', '机场名称')->options('/admin/data-aircraft')
->creationRules(['required', "unique:cars,aircraft_id,NULL,NULL,name,{$name}"], ['unique' => '数据已存在'])
->updateRules(['required', "unique:cars,aircraft_id,{$id},id,name,{$name}"], ['unique' => '数据已存在']);

 

 

posted @ 2019-07-02 11:18  六娃的博客  阅读(2501)  评论(0编辑  收藏  举报