/** * Finds the Link model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Link the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Link::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('app', 'PAGE_NOT_FOUND')); } }
protected function findModel($id) { if (($model = Link::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('未找到id为[' . $id . ']的链接'); } }
/** * Finds the Link model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Link the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Link::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Find model by short code * * @param $shortCode * @return null|Link * @throws NotFoundHttpException */ protected function findModelByShortCode($shortCode) { $model = Link::findOne(['short_code' => $shortCode]); if (!$model) { throw new NotFoundHttpException('The requested link doesn\'t exist'); } return $model; }
function actionAjaxdelete($id = null) { $link = Link::findOne($id); if ($link != null and $link['admin_id'] == Yii::$app->user->id) { if ($link->delete()) { echo '...'; } } else { echo 'нет данных...'; } }
public function actionGo($id) { User::loginGuest(); if (($link = Link::findOne($id)) !== null) { if (LinkStats::create($id) === true) { $this->redirect($link->href); } else { throw new NotFoundHttpException('Запрошеная страница не найдена.'); } } else { throw new NotFoundHttpException('Запрошеная страница не найдена.'); } }