Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Just exceptional. Thank you so much, Jack, you smashed it.

— Hugo, Developer

User Group Repository

To work with the with UserGroup Repository, use the following Facade:

use Statamic\Facades\UserGroup;

Methods

Methods Description
all() Get all User Groups
find($id) Get User Group by id
queryUsers() Query Builder for Users in a Group
make() Makes a new UserGroup instance

Querying

Examples

Get a User Group

UserGroup::find('admin')->get();

Get all users in a group

UserGroup::find('editors')
->queryUsers()
->get();

Find admins with an avatar

UserGroup::find('admin')
->queryUsers()
->where('avatar', true)
->get();

Creating

Start by making an instance of a user group with the make method. You can pass the handle into it.

$group = UserGroup::make('admin');

You may call additional methods on the group to customize it further.

$group
->title('Administrators')
->roles($roles); // array of role handles

Finally, save it.

$group->save();
HR: Section
Learn More!

There is more to learn more in these related articles:

shipment-container

Repositories

HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →