/**
  * Finds the Province model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @param integer $region_id
  * @return Province the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id, $region_id)
 {
     if (($model = Province::findOne(['id' => $id, 'region_id' => $region_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
use app\models\Employee;
use app\models\Province;
echo Province::findOne(['PROVINCE_ID' => 12])->PROVINCE_NAME;
/* @var $this yii\web\View */
/* @var $model app\models\Employee */
$this->title = $model->emp_id;
$this->params['breadcrumbs'][] = ['label' => 'Employees', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="employee-view">

    <h1>View <?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Update', ['update', 'id' => $model->emp_id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'id' => $model->emp_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'sex', 'value' => $model->sex === null ? '' : Employee::itemAlias('sex', $model->sex)], ['label' => 'ชื่อ-นามสกุล', 'value' => $model->getFullname()], 'fullName', 'address:ntext', 'zip_code', ['attribute' => 'birthday', 'format' => 'html', 'value' => Yii::$app->formatter->asDate($model->birthday, 'medium')], 'email:email', 'mobile_phone', 'position', 'salary', 'website:url', 'skill', 'countries', 'age', 'experience', 'personal_id', ['attribute' => 'sex', 'value' => $model->marital === null ? '' : Employee::itemAlias('marital', $model->marital)], 'provinces.PROVINCE_NAME', 'amphurs.AMPHUR_NAME', 'districts.DISTRICT_NAME', ['attribute' => 'province', 'value' => @Province::findOne(['PROVINCE_ID' => $model->province])->PROVINCE_NAME], 'provinceName', 'amphurName', 'districtName', 'social', ['attribute' => 'resume', 'format' => 'html', 'value' => !$model->resume ? '' : Html::a('ดาวน์โหลด', ['/employee/download', 'type' => 'resume', 'id' => $model->emp_id])], 'expire_date', 'create_date', 'modify_date']]);
?>

</div>