/**
  * Finds the AnRegions model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AnRegions the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AnRegions::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
/* @var $searchModel vov\announcement\backend\models\AnRegionsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'An Regions';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="an-regions-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create An Regions', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['label' => 'parentReg', 'attribute' => 'parentReg', 'value' => function ($searchModel) {
    $cat = \vov\announcement\backend\models\AnRegions::findOne(['id' => $searchModel->id]);
    $parentReg = $cat->parents(1)->one();
    return $parentReg->name;
}, 'filter' => yii\Helpers\ArrayHelper::map($searchModel->getParents(), 'id', 'name')], ['label' => 'local', 'attribute' => 'local', 'value' => 'local', 'filter' => \vov\announcement\common\helpers\NeccFunctions::getLanguages()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Esempio n. 3
0
 public function getParentReg()
 {
     $reg = AnRegions::findOne(['id' => $this->id]);
     $this->parentReg = $reg->parents(1)->one();
 }