public function actionIndex() { $curUser = \Yii::$app->user->id; UserSettingsBlock::sync($curUser); //todo return data model $block = Block::find()->with('links')->where(['hidden' => Block::STATUS_SHOW, 'type' => Block::TYPE_TAB])->orderBy('order')->all(); $model = UserSettingsBlock::find()->with('block')->orderBy('column, order')->where(['{{%user_settings_block}}.user_id' => $curUser])->all(); $msg = Message::find()->where(['status' => Message::STATUS_SHOW])->all(); return $this->render('index', ['model' => $model, 'blocks' => $block, 'messages' => $msg, 'link' => Link::getLinksBlocks()]); }
protected function findUserBlock($id) { $userId = \Yii::$app->user->id; $Id = (int) str_replace('item', '', $id); if (($model = UserSettingsBlock::find()->where(['user_id' => $userId, 'id' => $Id])->one()) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'PAGE_NOT_FOUND')); } }