/** * Creates a new SystemAuto model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new SystemAuto(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
protected function findModel($id) { if (($model = SystemAuto::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use frontend\modules\profile\models\SystemAuto; use yii\helpers\Url; $categorys = SystemAuto::getCategoryList(); ?> <div class="row"> <div class="col-md-12"> <ul id="list-category"> <?php foreach ($categorys as $id => $name) { ?> <?php $selectIcon = ''; $selectClass = ''; if (isset($_GET['AutoSearch']['category'])) { if ($_GET['AutoSearch']['category'] == $id) { $selectIcon = '2'; $selectClass = 'sel-img'; } } ?> <li> <a href="<?php echo Url::toRoute(['site/index', 'AutoSearch[category]' => $id, 'city_url' => $_GET['city_url']]); ?> " class='<?php echo $selectClass; ?> '>
protected function findModel($id) { if (($model = SystemAuto::findOne($id)) !== null) { return $model; } else { $this->setNotFoundHttpException(); } }
public function getSystemAutos() { return $this->hasMany(SystemAuto::className(), ['account_id' => 'id']); }