| Total Complexity | 6 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class ArticleController extends Controller |
||
| 10 | { |
||
| 11 | public function afterAction($action, $result) |
||
| 20 | } |
||
| 21 | |||
| 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 | ]); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function actionView($id) |
||
| 53 | ]); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @var Article $model |
||
| 58 | */ |
||
| 59 | private $model; |
||
| 60 | |||
| 61 | private function findModel($id) |
||
| 72 |