Get all groups.

UserGroup::all(); // Returns \Illuminate\Support\Collection

Get a group by ID.

UserGroup::find($id); // Returns UserGroup

Check if a group exists.

UserGroup::exists($id); // Returns a boolean

Get a group by handle.

UserGroup::whereHandle($handle); // Returns UserGroup

Get a user’s groups.

UserGroup::whereUser($user); // Returns \Illuminate\Support\Collection

This is the same getting the groups from the user, and depending on your use case, you might prefer doing this:


Import using:

use Statamic\API\UserGroup