'require|checkId', 'name' => 'require|unique:'.Skill::class.',name|max:32', 'is_show' => 'require|in:0,1', ]; protected $message = [ 'id.require' => '参数错误', 'name.require' => '请输入名称', 'name.unique' => '名称重复', 'name.max' => '名称不能超过32个字', 'is_show.require' => '请选择状态', 'is_show.in' => '状态取值范围在[0,1]', ]; public function sceneAdd() { return $this->remove(['id'=>true]); } public function sceneId() { return $this->only(['id']); } public function sceneStatus() { return $this->only(['id','is_show']); } /** * @notes 检验ID * @param $value * @param $rule * @param $data * @return bool|string * @author ljj * @date 2022/2/8 4:32 下午 */ public function checkId($value,$rule,$data) { $result = Skill::where('id',$value)->findOrEmpty(); if ($result->isEmpty()) { return '技能不存在'; } return true; } }