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' => '数据已存在']);