<?php

namespace app\controllers;

use Yii;
use app\models\Cabinet;
use yii\data\ActiveDataProvider;


class CabinetController extends \yii\web\Controller
{
    public function actionIndex()
    {
        $date = date("Y-m-d H:i:s");
        $query = Cabinet::find()
            ->where("bidding_date > '".$date."'")
            ->groupBy('name');

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        return $this->render('index', [
            'dataProvider' => $dataProvider,
        ]);
    }
    public function init()
    {
        //Yii::$app->session->get('user.flags'); exit;
        if(Yii::$app->user->isGuest)
        {
            return $this->redirect('/user/login');
        }
        else
        {
            $this->layout = '@app/views/layouts/backend/user';
        }
        $this->layout = '@app/views/layouts/backend/user';
    }

}
