本文整理匯總了PHP中Groups::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Groups::create方法的具體用法?PHP Groups::create怎麽用?PHP Groups::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Groups
的用法示例。
在下文中一共展示了Groups::create方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sgCreateGroup
public function sgCreateGroup()
{
$this->checkPermissions($_POST['_wpnonce'], 'sg-create-group');
$groupsObj = new Groups();
$groupsObj->returnMessages = true;
if (mb_strlen($_POST['name']) > 0) {
$result = $groupsObj->create(['name' => $_POST['name']]);
$output['result'] = $result['result'];
$output['messages'] = $result['messages']['error'];
} else {
$output['result'] = 0;
$output['messages'][] = __('Передано недостаточно данных');
}
echo json_encode($output, JSON_UNESCAPED_UNICODE);
die;
}
示例2: it_can_remove_members_in_group
/** @test **/
public function it_can_remove_members_in_group()
{
$users = $this->createUsers(4);
$group = Groups::create($users[0]->id, $this->data);
$group->addMembers([$users[1]->id, $users[2]->id]);
$this->assertEquals($group->fresh()->users->count(), 2);
$group->leave([$users[2]->id]);
$this->assertEquals(1, $group->fresh()->users->count());
}
示例3: createGroup
public function createGroup($owner)
{
$data = ['name' => 'Lorem'];
return Groups::create($owner, $data);
}