當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Course::findRoot方法代碼示例

本文整理匯總了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]);
 }
開發者ID:songwanfu,項目名稱:SummerNut,代碼行數:30,代碼來源:TaskController.php

示例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',
開發者ID:songwanfu,項目名稱:SummerNut,代碼行數:31,代碼來源:view.php

示例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>

開發者ID:songwanfu,項目名稱:SummerNut,代碼行數:29,代碼來源:index.php


注:本文中的app\models\Course::findRoot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。