本文整理汇总了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]);
}
示例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]);
}
示例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>
示例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));
}
}
}