laravel-admin表单验证

范浩宕
2023-12-01
$form->text("name", "姓名")
->creationRules('required|unique:table', ['required' => '姓名不能为空','unique' => '姓名不能重复'])
->updateRules('required|unique:table,name,{{id}}', ['required' => '姓名不能为空','unique' => '姓名不能重复'])
->required();
//table:表名
//creationRules:新增时验证
//updateRules:编辑时验证,table表排除条件id为当前id的数据,name不能重复
//{{id}}:照常写即可
//required():必填字段加红星标识
 类似资料: