order('gr_id ASC'); if (!empty($title)) { $query->whereLike('title', '%' . $title . '%'); } $list = $query->paginate([ 'page' => $page, 'list_rows' => $pagesize, ]); return $list; } /** * 添加分组 * * @param array $data 数据 * @return bool */ public function add($data) { $db = new Db(); $result = $db->name('group')->insert($data); if ($result) { return true; } return false; } /** * 获取分组信息 * * @param int $id 分组ID * @return array|null */ public function getGroup($id) { $group = $this->find($id); if ($group) { return $group->toArray(); } return null; } /** * 更新分组信息 * * @param int $id 分组ID * @param array $data 数据 * @return bool */ public function updateGroup($id, $data) { $result = $this->where('id', $id)->update($data); if ($result !== false) { return true; } return false; } /** * 更新审核状态 * * @param int $gr_id 课程ID * @param array $data 数据 * @return bool */ public function updateAuditStatus($gr_id, $data) { $result = $this->where('gr_id', $gr_id)->update($data); if ($result !== false) { return true; } return false; } /** * 编辑分组 * * @param int $id 分组ID * @param array $data 分组数据 * @return bool */ public function edit($id, $data) { $result = $this->where('gr_id', $id)->update($data); return $result !== false; } /** * 删除分组 * * @param int $id 分组ID * @return bool */ public function deleteGroup($id) { $result = $this->where('id', $id)->delete(); if ($result > 0) { return true; } return false; } }