search($where)->when($with, function ($query) use ($with) { $query->with($with); })->field($field)->when($page && $limit, function ($query) use ($page, $limit) { $query->page($page, $limit); })->order('sort desc,id desc')->select()->toArray(); } /** * 获得所有同类型任务 * @param int $type * @param int $grade * @return array|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getTypTaskList(int $type) { return $this->getModel()->with(['levelGrade'])->where('type', $type)->where('is_del', 0)->where('status', 1)->order('number desc')->select()->toArray(); } }