public function actionManage($id) { \yii::$app->jsconfig->addData('searchUri', Url::to(['ajax/searchusers'])); \yii::$app->jsconfig->addData('memberTargetId', '#member-select'); \yii::$app->jsconfig->addData('managerTargetId', '#manager-select'); \yii::$app->jsconfig->addData('collectionId', $id); \yii::$app->jsconfig->addData('addUri', Url::to(['ajax/adduser'])); \yii::$app->jsconfig->addData('removeUri', Url::to(['ajax/removeuser'])); \yii::$app->jsconfig->addData('memberType', Types::$member_type['member']['id']); \yii::$app->jsconfig->addData('managerType', Types::$member_type['manager']['id']); $collectionModel = Collection::findOne($id); if ($collectionModel === null) { throw new \yii\web\HttpException(404, yii::t('app', 'Cannot find collection.')); } return $this->render('manage', ['collectionModel' => $collectionModel]); }
/** * Finds the Collection model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Collection the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Collection::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }