public function getIsTeacher() { if (Teacher::findOne(['user_id' => $this->id])) { return true; } else { return false; } }
use yii\helpers\Html; use yii\widgets\ListView; use common\models\Lesson; use common\models\GroupHasDiscipline; use yii\helpers\Url; use common\models\Teacher; use yii\web\NotFoundHttpException; use yii\bootstrap\Tabs; use common\widgets\Schedule; use yii\bootstrap\Modal; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ $date = new DateTime(); $todayDate = $date->format("Y-m-d"); $Teacher = Teacher::findOne($teacher); if (!$Teacher) { throw new NotFoundHttpException('Страница не найдена.'); } //if(!$ghd) { echo Html::tag('h3','Расписания данной группы не существует или оно еще не заполнено!'); return;} $this->title = 'Расписание преподавателя ' . $Teacher->user->fullname; $this->params['breadcrumbs'][] = ['label' => 'Информация', 'url' => Url::to(['site/information'])]; $this->params['breadcrumbs'][] = ['label' => 'Расписание', 'url' => Url::to(['lesson/index'])]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="lesson-index"> <h3><?php echo "Расписание преподавателя: " . Html::button($Teacher->user->fullname, ['class' => 'btn btn-lg btn-link modalButton', 'value' => Url::to(['//teacher/view', 'id' => $Teacher->id])]); ?> </h3>
/** * Finds the Teacher model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Teacher the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Teacher::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }