Conditions | 1 |
Paths | 1 |
Total Lines | 22 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function actionIndex() |
||
12 | { |
||
13 | $query = Article::find() |
||
14 | ->alias('a') |
||
15 | ->joinWith('category') |
||
16 | ->where([ |
||
17 | 'a.status' => StatusInterface::STATUS_ACTIVE, |
||
18 | 'a.is_deleted' => 0, |
||
19 | ]) |
||
20 | ->andWhere(['<=', 'a.release_time', time()]) |
||
21 | ->orderBy(['a.release_time' => SORT_DESC]); |
||
22 | |||
23 | $count = $query->count(); |
||
24 | $pagination = new Pagination(['totalCount' => $count]); |
||
25 | |||
26 | $articles = $query->offset($pagination->offset) |
||
27 | ->limit($pagination->limit) |
||
28 | ->all(); |
||
29 | |||
30 | return $this->render('index', [ |
||
31 | 'articles' => $articles, |
||
32 | 'pagination' => $pagination, |
||
33 | ]); |
||
54 | } |