Conditions | 1 |
Paths | 1 |
Total Lines | 22 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function actionIndex() |
||
23 | { |
||
24 | $query = Article::find() |
||
25 | ->alias('a') |
||
26 | ->joinWith('category') |
||
27 | ->where([ |
||
28 | 'a.status' => StatusInterface::STATUS_ACTIVE, |
||
29 | 'a.is_deleted' => 0, |
||
30 | ]) |
||
31 | ->andWhere(['<=', 'a.release_time', time()]) |
||
32 | ->orderBy(['a.release_time' => SORT_DESC]); |
||
33 | |||
34 | $count = $query->count(); |
||
35 | $pagination = new Pagination(['totalCount' => $count]); |
||
36 | |||
37 | $articles = $query->offset($pagination->offset) |
||
38 | ->limit($pagination->limit) |
||
39 | ->all(); |
||
40 | |||
41 | return $this->render('index', [ |
||
42 | 'articles' => $articles, |
||
43 | 'pagination' => $pagination, |
||
44 | ]); |
||
72 |