本文整理匯總了PHP中app\models\Group::addGroupUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Group::addGroupUser方法的具體用法?PHP Group::addGroupUser怎麽用?PHP Group::addGroupUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Group
的用法示例。
在下文中一共展示了Group::addGroupUser方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionGroup
/**
* 配置項目
*
* @param $projectId
* @return string
* @throws \Exception
*/
public function actionGroup($projectId)
{
// 配置信息
$project = $this->findModel($projectId);
// 添加用戶
if (\Yii::$app->request->getIsPost() && \Yii::$app->request->post('user')) {
Group::addGroupUser($projectId, \Yii::$app->request->post('user'));
}
// 項目的分組用戶
$group = Group::find()->with('user')->where(['project_id' => $projectId])->indexBy('user_id')->orderBy(['type' => SORT_DESC])->asArray()->all();
// 所有用戶
$users = User::find()->select(['id', 'email', 'realname'])->where(['is_email_verified' => 1])->asArray()->all();
return $this->render('group', ['conf' => $project, 'users' => $users, 'group' => $group]);
}
示例2: actionGroup
/**
* 配置項目
*
* @param $projectId
* @return string
* @throws \Exception
*/
public function actionGroup($projectId)
{
// 配置信息
$project = Project::findOne($projectId);
if (!$project) {
throw new \Exception('項目不存在:)');
}
if ($project->user_id != $this->uid) {
throw new \Exception('不可以操作其它人的項目:)');
}
// 添加用戶
if (\Yii::$app->request->getIsPost() && \Yii::$app->request->post('user')) {
Group::addGroupUser($projectId, \Yii::$app->request->post('user'));
}
// 項目的分組用戶
$group = Group::find()->with('user')->where(['project_id' => $projectId])->indexBy('user_id')->asArray()->all();
// 所有用戶
$users = User::find()->select(['id', 'email', 'realname'])->where(['is_email_verified' => 1])->asArray()->all();
return $this->render('group', ['conf' => $project, 'users' => $users, 'group' => $group]);
}
示例3: afterSave
/**
* 添加數據保存事件afterSave
*
* @author wushuiyong
* @param bool $insert
* @param array $changedAttributes
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
// 插入一條管理員關係
if ($insert) {
Group::addGroupUser($this->attributes['id'], [$this->attributes['user_id']], Group::TYPE_ADMIN);
}
}
示例4: afterSave
/**
* 添加數據保存事件afterSave
*
* @author wushuiyong
* @param bool $insert
* @param array $changedAttributes
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
// 修改了項目repo_url,本地檢出代碼將被清空
if (isset($changedAttributes['repo_url'])) {
$projectDir = static::getDeployFromDir();
if (file_exists($projectDir)) {
$folder = new Folder($this);
$folder->removeLocalProjectWorkspace($projectDir);
}
}
// 插入一條管理員關係
if ($insert) {
Group::addGroupUser($this->attributes['id'], [$this->attributes['user_id']], Group::TYPE_ADMIN);
}
}