本文整理汇总了PHP中app\models\Course::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::findOne方法的具体用法?PHP Course::findOne怎么用?PHP Course::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::findOne方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findModel
protected function findModel($id)
{
if (($model = Course::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例2: actionRegister
public function actionRegister($co = null, $cl = null)
{
$model = new Student();
if ($model->load(Yii::$app->request->post())) {
$model->course_id = $co;
$model->classid = $cl;
$model->created_dt = date('Y-m-d H:i:s');
$model->save();
return $this->redirect(['success']);
//return $this->redirect(['view', 'id' => $model->id]);
} else {
if (!empty($co)) {
$courselist = Course::findOne($co);
}
return $this->render('register', ['model' => $model, 'courselist' => $courselist]);
}
}
示例3:
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use app\models\User;
use app\models\Course;
/* @var $this yii\web\View */
/* @var $model app\models\UserHasCourse */
$this->title = $model->user_id;
$this->params['breadcrumbs'][] = ['label' => 'User Has Courses', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-has-course-view">
<?php
echo DetailView::widget(['model' => $model, 'attributes' => [['label' => 'User', 'value' => User::findOne($model->user_id)->first_name . ' ' . User::findOne($model->user_id)->last_name . ' ( ' . User::findOne($model->user_id)->username . ' )'], ['label' => 'Course', 'value' => Course::findOne($model->course_id)->code . ' ( ' . Course::findOne($model->course_id)->name . ' )']]]);
?>
<p>
<?php
echo Html::a('Update', ['update', 'user_id' => $model->user_id, 'course_id' => $model->course_id], ['class' => 'btn btn-primary']);
?>
<?php
echo Html::a('Delete', ['delete', 'user_id' => $model->user_id, 'course_id' => $model->course_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
</p>
</div>
示例4: _pickStudentAssistant
/**
* Show the student assistant picking page
*
* @param $model
* @param $course_id
* @return string
*/
private function _pickStudentAssistant($model, $course_id)
{
// Fetch all students assistants
$course = Course::findOne($course_id);
return $this->render('pickSA', ['model' => $model, 'sas' => $course->studentAssistants]);
}