1
0
Fork 0

更新 app/Admin/Services/KeywordService.php

panliang 2023-12-01 10:45:06 +08:00
parent 35bd7eea05
commit 97ba05b6c6
1 changed files with 3 additions and 3 deletions

View File

@ -49,16 +49,16 @@ class KeywordService extends BaseService
return true;
}
public function validate($data, $id = null)
public function validate($data, $model = null)
{
$createRules = [
'key' => ['required', Rule::unique('keywords', 'key')],
'name' => ['required'],
];
$updateRules = [
'key' => [Rule::unique('keywords', 'key')->ignore($id)]
'key' => [Rule::unique('keywords', 'key')->ignore($model->id)]
];
$validator = Validator::make($data, $id ? $updateRules : $createRules, [
$validator = Validator::make($data, $model ? $updateRules : $createRules, [
'key.unique' => ':input 已经存在'
]);
if ($validator->fails()) {