本文整理匯總了PHP中app\models\Course::findRoot方法的典型用法代碼示例。如果您正苦於以下問題:PHP Course::findRoot方法的具體用法?PHP Course::findRoot怎麽用?PHP Course::findRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Course
的用法示例。
在下文中一共展示了Course::findRoot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionCreate
/**
* Creates a new Task model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$course_id = Yii::$app->request->get('course_id');
$model = new Task();
if ($model->load(Yii::$app->request->post())) {
$model = $model->validateAttr($model);
if (empty($model->errors)) {
$resourceModel = new Resource();
$model = $resourceModel->uploadImg($model, 'image');
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
}
}
$model->course_id = $course_id;
if (!json_decode($model->answer_json)) {
$model->answer_json = '';
}
$chapterName = $courseName = null;
if (!empty($course_id)) {
$chapterName = Course::findModel($course_id)->name;
$courseName = Course::findRoot($course_id)->name;
}
return $this->render('create', ['model' => $model, 'courseId' => $course_id, 'chapterName' => $chapterName, 'courseName' => $courseName]);
}
示例2:
'attribute' => 'status',
'value' => $statusList[$model->status],
],
[
'attribute' => 'resource_type',
'value' => $typeList[$model->resource_type],
],
[
'attribute' => 'course_id',
'label' => Yii::t('app', 'Chapter'),
'value' => Course::findModel($model->course_id)->name,
],
[
'attribute' => 'course_id',
'label' => Yii::t('app', 'Course'),
'value' => Course::findRoot($model->course_id)->name,
],
'play_count',
'download_count',
'create_time',
'update_time',
],
]) ?>
<p>
<?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
'method' => 'post',
示例3: function
return Html::a($model->name . '.' . $model->extension, ["play?id=$model->id"]);
}
],
'size',
// 'duration',
[
'label' => Yii::t('app', 'Chapter'),
'value' => function ($model) {
return Course::findModel($model->course_id)->name;
}
],
[
'label' => Yii::t('app', 'Course'),
'attribute' => 'course_id',
'value' => function ($model) {
return Course::findRoot($model->course_id)->name;
}
],
'play_count',
'download_count',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>