for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Itstructure\AdminModule\controllers;
use yii\web\NotFoundHttpException;
use Itstructure\AdminModule\models\{Language, LanguageSearch};
/**
* Class LanguageController
* LanguageController implements the CRUD actions for Language model.
*
* @package Itstructure\AdminModule\controllers
* @author Andrey Girnik <[email protected]>
*/
class LanguageController extends CommonAdminController
{
* Initialize.
public function init()
$this->viewPath = '@admin/views/language';
$this->setEditingScenarios = true;
parent::init();
}
* Set language as default.
* @param $languageId
* @return \yii\web\Response
* @throws NotFoundHttpException
public function actionSetDefault($languageId)
$language = Language::findOne($languageId);
if (null === $language) {
throw new NotFoundHttpException('Language with id ' . $languageId . ' does not exist');
$language->default = $language->default == 0 ? 1 : 0;
$language->default
mixed|null
0
0 == 0
null == 0
===
$language->save();
return $this->redirect('index');
* Returns Language model name.
* @return string
protected function getModelName():string
return Language::class;
* Returns LanguageSearch model name.
protected function getSearchModelName():string
return LanguageSearch::class;