BlogController.php 988 Bytes
<?php
    
    namespace frontend\controllers;
    
    use artbox\weblog\models\Article;
    use yii\data\ActiveDataProvider;
    use yii\web\Controller;
    
    /**
     * Class BlogController
     *
     * @package frontend\controllers
     */
    class BlogController extends Controller
    {
        public function actionIndex()
        {
            $query = Article::find()
                            ->with('lang.alias')
                            ->with('image')
                            ->where([ 'status' => true ]);
            
            $dataProvider = new ActiveDataProvider(
                [
                    'query'      => $query,
                    'pagination' => [
                        'pageSize' => 3,
                    ],
                ]
            );
            
            return $this->render(
                'index',
                [
                    'dataProvider' => $dataProvider,
                ]
            );
        }
    }