$type, 'relation_id' => $id, 'staff_id' => $staff->id ]; $Model = new self; // 调用当前模型对应的User验证器类进行数据验证 $result = $Model->save($data); if (false === $result) { // 验证失败 输出错误信息 throw new Exception($Model->getError()); } return true; } //取消重点关注 public static function cancel($type, $id) { $Model = new self; // 调用当前模型对应的User验证器类进行数据验证 $result = $Model->destroy(['relation_type' => $type, 'relation_id' => $id]); if (false === $result) { // 验证失败 输出错误信息 throw new Exception($Model->getError()); } return true; } //是否重点关注 public static function isCollect($type, $id) { $staff = Staff::info(); $where = [ 'relation_type' => $type, 'relation_id' => $id, 'staff_id' => $staff->id ]; $Model = new self; // 调用当前模型对应的User验证器类进行数据验证 if ($Model->where($where)->find()) { return true; } return false; } }