本文整理汇总了PHP中app\models\Menu::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Menu::findOne方法的具体用法?PHP Menu::findOne怎么用?PHP Menu::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Menu
的用法示例。
在下文中一共展示了Menu::findOne方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findModel
protected function findModel($id)
{
if (($model = Menu::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例2: validateUrl
public function validateUrl($attribute, $params)
{
$row = Menu::findOne(['url' => $this->url]);
if ($row) {
//if ($row->id != $this->post_id){
$this->addError($attribute, 'Пункт меню с таким URI уже существует.');
//}
}
}
示例3: actionCreate
/**
* Creates a new Link model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @param integer $menuId
* @return mixed
*/
public function actionCreate($menuId)
{
$model = new Link();
if ($model->load(Yii::$app->request->post())) {
$model->menu_id = $menuId;
if ($model->save()) {
return $this->redirect(['menu/view', 'id' => $model->menu_id]);
}
} else {
return $this->render('create', ['model' => $model, 'menu' => Menu::findOne($menuId)]);
}
}
示例4: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Menu::findOne($id);
if ($model === null) {
throw new \yii\web\HttpException(404, 'The requested page does not exist.');
}
return $model;
}