/** * Finds the MGoodscat model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return MGoodscat the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = MGoodscat::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\grid\GridView; use app\models\MGoods; use app\models\MGoodsSearch; use app\models\MGoodscat; /* @var $this yii\web\View */ /* @var $searchModel app\models\MGoodsSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ use app\models\U; $goods_kind = $_GET["goods_kind"]; $goodscat = MGoodscat::findOne(['value' => $goods_kind]); $this->title = '商品列表'; ?> <div class="mgoods-index"> <h4><?php echo Html::encode($this->title); ?> | <?php echo empty($goodscat) ? '' : $goodscat->cat; ?> </h4> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <!-- <p> <//?= Html::a('新增商品', ['create'], ['class' => 'btn btn-success']) ?>