public function getAccess($controller) { $allow = false; $accesses = Access::findAll(["profile_id" => Yii::$app->user->identity->profile_id]); foreach ($accesses as $accesses) { $module = Module::findOne(["id" => $accesses->module_id]); if ($module->controller === $controller) { $allow = true; break; } } return $allow; }
/** * Finds the Module model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Module the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Module::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }