where('room_no', $value); } public function searchUserIdAttribute($query, $value, array $params): mixed { if (empty($value)) { return $query; } return $query->where('user_id', $value); } /** * 添加关键词 * @param int $user_id * @param int $room_id * @param string $room_no * @param string $keyword * @return bool */ public function add(int $user_id,int $room_id, string $room_no, string $keyword): bool { $data = [ 'user_id' => $user_id, 'room_id' => $room_id, 'room_no' => $room_no, 'keyword' => $keyword, ]; if (!$this->query()->insert($data)){ return $this->error('添加失败'); } return $this->success('添加成功'); } /** * 添加关键词 * @param int $id * @return bool */ public function del(int $id): bool { if (!$this->query()->where('id',$id)->delete()){ return $this->error('删除失败'); } return $this->success('删除成功'); } // 主播信息 public function user() { return $this->hasOne(UserModel::class, 'id', 'user_id'); } }