Example #1
0
 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(10)->asArray()->all();
     $pages = new Pagination(['totalCount' => $tasks->count(), 'pageSize' => 10]);
     return $this->render('list', ['list' => $list, 'pages' => $pages, 'audit' => $auditProjects]);
 }