All packages
Teams for Laravel
Team settings
Each team carries a small set of typed governance settings, stored through options-for-laravel. Unset settings fall back to their defaults, so a team that never touches them behaves exactly as before:
use RoundlyConsulting\Teams\Enums\JoinPolicy;
use RoundlyConsulting\Teams\Facades\Teams;
Teams::for($team)->settings()
->setJoinPolicy(JoinPolicy::Open) // Open | Request (default) | InviteOnly
->setMaxSeats(50) // null = unlimited (default)
->setDefaultMemberRole('member') // overrides teams.roles.default for this team
->setRequireApprovalToJoin(true); // hold Open-team requests pending
$settings = Teams::for($team)->settings();
$settings->joinPolicy(); // JoinPolicy enum
$settings->maxSeats(); // ?int
$settings->defaultMemberRole(); // ?string
$settings->requireApprovalToJoin(); // bool| Option class | Default | Effect |
|---|---|---|
JoinPolicy | Request | InviteOnly: joinRequests()->open() throws TeamsException. Open: a request for the default role is auto-approved and the requester joins with it; a request for any other role stays pending. Request: every request stays pending for a decision. |
MaxSeats | null (unlimited) | Adding a new member throws TeamsException once active members reach the cap. |
DefaultMemberRole | null | Role used when a request is approved with none supplied; falls back to roles.default. |
RequireApprovalToJoin | false | Keeps requests to an Open team pending instead of auto-approving them. |
Passing null to setMaxSeats() or setDefaultMemberRole() removes the stored value and restores the default.
Reading and writing one option
Each setting is an option class under RoundlyConsulting\Teams\Options, so you can address one directly:
use RoundlyConsulting\Teams\Options\MaxSeats;
$team->option(MaxSeats::class)->set(50);Handling a full team
use RoundlyConsulting\Teams\Exceptions\TeamsException;
try {
Teams::for($team)->members()->add($user, 'member');
} catch (TeamsException $e) {
// "This team has reached its seat limit of 50."
}Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.