示例#1
0
 /**
  * Finds the Khoa model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Khoa the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Khoa::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
/* @var $this yii\web\View */
/* @var $searchModel app\models\PhongkhamSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Phòng khám';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="phongkham-index">

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

    <p>
        <?php 
echo Html::a('Tạo phòng khám', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', 'maKhoa', 'tenPK', ['label' => 'Thuộc khoa', 'format' => 'raw', 'value' => function ($data) {
    $url = \app\models\Khoa::findOne(['id' => $data->maKhoa]);
    return $url->tenKhoa;
}], 'moTa:ntext', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>