60 lines
954 B
PHP
60 lines
954 B
PHP
<?php
|
|
|
|
namespace app\controllers;
|
|
|
|
use app\models\ComputationResult;
|
|
use Yii;
|
|
use yii\filters\AccessControl;
|
|
use yii\web\Controller;
|
|
use yii\web\Response;
|
|
use yii\filters\VerbFilter;
|
|
use app\models\LoginForm;
|
|
use app\models\ContactForm;
|
|
use app\models\DeckForm;
|
|
|
|
class SiteController extends Controller
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function actions()
|
|
{
|
|
return [
|
|
'error' => [
|
|
'class' => 'yii\web\ErrorAction',
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Displays homepage.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function actionIndex()
|
|
{
|
|
$computation_result = new ComputationResult();
|
|
$deck_form = new DeckForm();
|
|
if ($deck_form->load(Yii::$app->request->post()))
|
|
{
|
|
if ($deck_form->validate())
|
|
{
|
|
$computation_result = $deck_form->compute();
|
|
}
|
|
}
|
|
return $this->render('index', [
|
|
'deck_form' => $deck_form,
|
|
'result' => $computation_result,
|
|
]);
|
|
}
|
|
}
|