Total Complexity | 4 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class ArticleController extends Controller |
||
10 | { |
||
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 | ]); |
||
34 | } |
||
35 | |||
36 | public function actionView($id) |
||
42 | ]); |
||
43 | } |
||
44 | |||
45 | private function findModel($id) |
||
53 | } |
||
54 | } |