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


PHP Activity::getOneActivityNameById方法代碼示例

本文整理匯總了PHP中app\models\Activity::getOneActivityNameById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Activity::getOneActivityNameById方法的具體用法?PHP Activity::getOneActivityNameById怎麽用?PHP Activity::getOneActivityNameById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Activity的用法示例。


在下文中一共展示了Activity::getOneActivityNameById方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionView

 /**
  * Displays a single ActivityUsers model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $model->activityName = Activity::getOneActivityNameById($model->activity_id);
     $model->userName = Users::getOneUserNameById($model->user_id);
     return $this->render('view', ['model' => $model]);
 }
開發者ID:hanxiao84322,項目名稱:coach_system,代碼行數:12,代碼來源:ActivityUsersController.php

示例2: actionApplySuccess

 public function actionApplySuccess()
 {
     $activityUserId = Yii::$app->request->get('id');
     $activityUser = ActivityUsers::findOne(['id' => $activityUserId]);
     $maxCount = ActivityUsers::getMaxSignUpOrder($activityUser['activity_id']);
     $activityName = Activity::getOneActivityNameById($activityUser['activity_id']);
     $data = ['maxCount' => $maxCount, 'activityName' => $activityName];
     return $this->redirect(['/activity/apply-success', 'data' => $data]);
 }
開發者ID:hanxiao84322,項目名稱:coach_system,代碼行數:9,代碼來源:ActivityController.php

示例3:

?>

<div class="attendance-form">

    <?php 
$form = ActiveForm::begin();
?>


    <div class="form-group field-trainusers-trainname">
        <label class="control-label" for="trainusers-trainname">參與培訓課程:</label>
        <a href="/Admin/train/index?TrainSearch[id]=<?php 
echo $model->activity_id;
?>
" target="_blank" style="width:300px"><?php 
echo \app\models\Activity::getOneActivityNameById($model->activity_id);
?>
</a>
        <div class="help-block"></div>
    </div>
    <div class="form-group field-trainusers-username">
        <label class="control-label" for="trainusers-username">參與學員:</label>
        <a href="/Admin/users/index?UsersSearch[id]=<?php 
echo $model->activity_id;
?>
" target="_blank" style="width:300px"><?php 
echo \app\models\Users::getOneUserNameById($model->user_id);
?>
</a>
        <div class="help-block"></div>
    </div>
開發者ID:hanxiao84322,項目名稱:coach_system,代碼行數:31,代碼來源:_form.php

示例4: actionActivityApply

 public function actionActivityApply()
 {
     $activityId = Yii::$app->request->get('id');
     $activityInfo = Activity::findOne(['id' => $activityId]);
     $levelId = $activityInfo['level_id'];
     if ($activityInfo['status'] != Activity::BEGIN_SIGN_UP) {
         throw new ServerErrorHttpException('該活動的狀態不是開始報名,謝謝。');
     }
     if (Yii::$app->user->isGuest) {
         return $this->redirect('/login/login');
     } else {
         $userId = Yii::$app->user->id;
         if (Yii::$app->user->identity->status != '1') {
             throw new ServerErrorHttpException('係統錯誤,原因:您目前的狀態是未審核,不能報名活動,謝謝。');
         }
         $activityLevelInfo = Level::findOne(['id' => $activityInfo['level_id']]);
         if ($activityLevelInfo['order'] != Yii::$app->user->identity->level_order) {
             throw new ServerErrorHttpException('係統錯誤,原因:您目前沒有權限報名該級別下的活動,謝謝。');
         }
         //檢查用戶參與的活動,狀態不是取消的都算是已經參與了報名
         $isExist = ActivityUsers::getUserIsExistActivityStatus($userId, $activityInfo['level_id']);
         if (!empty($isExist)) {
             throw new ServerErrorHttpException('係統錯誤,原因:您已經參與了該級別下的活動,請耐心等待活動結果,謝謝。');
         }
         //報名成功,給出用戶的序號
         $activityUsersOrder = ActivityUsers::getActivityUsersOrder($userId, $activityId);
         if (empty($activityUsersOrder)) {
             $activityUsersOrder = 1;
         }
         $transaction = Yii::$app->db->beginTransaction();
         $data = ['activity_id' => $activityId, 'user_id' => $userId, 'status' => ActivityUsers::APPROVED, 'level_id' => $levelId, 'orders' => $activityUsersOrder];
         $model = new ActivityUsers();
         $model->setAttributes($data);
         if ($model->save()) {
             $activityUserId = $model->id;
             $activityUser = ActivityUsers::findOne(['id' => $activityUserId]);
             $activityName = Activity::getOneActivityNameById($activityUser['activity_id']);
             $data = ['orders' => $activityUser['orders'], 'activityName' => $activityName];
             //新增一條用戶和級別對應的信息
             $result = UsersLevel::updateAll(['activity_id' => $activityId], ['user_id' => $userId, 'level_id' => $levelId]);
             if (!$result) {
                 $transaction->rollBack();
                 throw new ServerErrorHttpException('更新狀態錯誤,原因:更新數據庫錯誤!');
             } else {
                 $transaction->commit();
             }
             return $this->render('/activity/apply-success', ['data' => $data]);
         } else {
             throw new ServerErrorHttpException('係統錯誤,原因:' . json_encode($model->errors, JSON_UNESCAPED_UNICODE));
         }
     }
 }
開發者ID:hanxiao84322,項目名稱:coach_system,代碼行數:52,代碼來源:UserCenterController.php


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