app\controllers\TaskController::actionIndex PHP 메소드

actionIndex() 공개 메소드

我的上线列表
public actionIndex ( integer $page = 1, integer $size = 10 ) : string
$page integer
$size integer
리턴 string
    public function actionIndex($page = 1, $size = 10)
    {
        $size = $this->getParam('per-page') ?: $size;
        $list = Task::find()->with('user')->with('project')->where(['user_id' => $this->uid]);
        // 有审核权限的任务
        $auditProjects = Group::getAuditProjectIds($this->uid);
        if ($auditProjects) {
            $list->orWhere(['project_id' => $auditProjects]);
        }
        $kw = \Yii::$app->request->post('kw');
        if ($kw) {
            $list->andWhere(['or', "commit_id like '%" . $kw . "%'", "title like '%" . $kw . "%'"]);
        }
        $tasks = $list->orderBy('id desc');
        $list = $tasks->offset(($page - 1) * $size)->limit($size)->asArray()->all();
        $pages = new Pagination(['totalCount' => $tasks->count(), 'pageSize' => $size]);
        return $this->render('list', ['list' => $list, 'pages' => $pages, 'audit' => $auditProjects]);
    }