I have this code in layout/main.php:
$userId = Yii::$app->user->id;
$data = User::find()->where('id ="'.$userId.'"')->one();
$type = $data['type'];
Yii::$app->view->params['Type'] = $type;
I cant' access $this->params['Type']
from any controller except SiteController
. If I navigated using any another controller i got this error:
PHP Notice – yii\base\ErrorException
Undefined index: Type
If I duplicated my query in every controller, It works well. But I don't want to do that. How to make it globally at the backend
only?