GroupMenu.php 781 Bytes
<?php

namespace frontend\modules\news\widgets\GroupMenu;

use frontend\modules\news\models\Group;

/**
 * Class GroupMenu
 *
 * @package frontend\modules\news\widgets\LatestNews
 * @author FilamentV <vortex.filament@gmail.com>
 * @copyright (c), Thread
 */
class GroupMenu extends \thread\app\base\widgets\Widget
{
    public $limit = 10;
    /**
     * @var null
     */
    protected $items = null;

    /**
     *
     */
    public function init()
    {
        parent::init();

        $this->items = Group::find()->addOrderBy(['title' => SORT_ASC])->all();

    }

    /**
     *
     */
    public function run()
    {
        if ($this->items != null) {
            return $this->render('index', [
                'groups' => $this->items
            ]);
        }
    }
}