public static function getTeacherById($id) { $teacher = Teachers::findOne(['id' => $id]); $retVal = array(); $retVal['id'] = $teacher->id; $retVal['name'] = $teacher->name; $retVal['description'] = $teacher->description; $retVal['avatar'] = $teacher->avatar; $retVal['email'] = $teacher->email; $retVal['phone'] = $teacher->phone; $retVal['website'] = $teacher->website; $retVal['address'] = $teacher->address; $retVal['research'] = $teacher->research; if ($teacher->number_rated != 0) { $retVal['stars'] = round($teacher->stars / $teacher->number_rated); $retVal['number_rated'] = $teacher->number_rated; } else { $retVal['stars'] = 1; $retVal['number_rated'] = 1; } $retVal['department'] = Departments::findOne(['id' => $teacher->department])->name; $retVal['created_at'] = Date('d/m/Y', $teacher->created_at); $retVal['updated_at'] = Date('d/m/Y', $teacher->updated_at); return $retVal; }
public function actionSuggest() { $request = Yii::$app->request; $department_id = $request->get('id'); $department_name = Departments::findOne(['id' => $department_id])->name; Yii::$app->view->title = 'Chương trình đào tạo ngành: ' . $department_name; Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => 'Bluebee-UET.com - Chương trình đào tạo ngành: ' . $department_name]); Yii::$app->view->registerMetaTag(['property' => 'og:title', 'content' => 'Bluebee-UET.com - Chương trình đào tạo ngành: ' . $department_name]); Yii::$app->view->registerMetaTag(['property' => 'og:description', 'content' => 'Bluebee-UET.com - Chương trình đào tạo ngành: ' . $department_name]); Yii::$app->view->registerMetaTag(['property' => 'og:image', 'content' => 'http://bluebee-uet.com/img/logo.jpg']); return $this->render('index', ['department_name' => $department_name, 'department_id' => $department_id]); }
public function actionGetTeachersByDepartment() { $request = Yii::$app->request; try { $department = HtmlPurifier::process($request->get('id', '')); $teachers = Teachers::getTeachersByDepartment($department); $department_name = Departments::findOne(['id' => $department])->name; Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => 'Bluebee-UET.com - Giảng viên ngành: ' . $department_name]); Yii::$app->view->registerMetaTag(['property' => 'og:title', 'content' => 'Bluebee-UET.com - Giảng viên ngành: ' . $department_name]); Yii::$app->view->registerMetaTag(['property' => 'og:description', 'content' => 'Bluebee-UET.com - Giảng viên ngành: ' . $department_name]); Yii::$app->view->registerMetaTag(['property' => 'og:image', 'content' => 'http://bluebee-uet.com/img/logo.jpg']); Yii::$app->view->title = 'Giảng viên ngành: ' . $department_name; return $this->render('teachers', $teachers); } catch (Exception $ex) { } }
?> </td> <td><?php echo $model->website; ?> </td> <td><?php echo $model->stars; ?> </td> <td><?php echo $model->number_rated; ?> </td> <td><?php echo \app\models\Departments::findOne(['id' => $model->department])->name; ?> </td> <td><?php echo Date('d/m/Y', $model->created_at); ?> </td> <td> <a class="btn btn-default admin-update" href="#" data-toggle="modal" data-target="#modal-admin-update" data-id="<?php echo $model->id; ?> ">Edit</a> <a class="btn btn-danger admin-delete" href="#" data-toggle="modal" data-target="#modal-admin-delete" data-id="<?php echo $model->id; ?> ">Delete</a>
/** * Finds the Departments model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Departments the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Departments::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function setDepartments($input) { $departments = Departments::findOne($input['id']); $departments->condition = $input['type']; $departments->save(); }