本文整理汇总了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>