Looking to hire Laravel developers? Try LaraJobs

laravel-teams maintained by jeffersongoncalves

Description
A Laravel package that adds Teams, memberships, and team invitations with multi-tenancy support to your application.
Last update
2026/06/24 13:54 (dev-master)
License
Downloads
0

Comments
comments powered by Disqus

Laravel Teams

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Framework-agnostic Teams core for Laravel: Eloquent models, memberships, team invitations, a HasTeams user trait, a team policy, and configurable models/tables. This is the foundation package consumed by jeffersongoncalves/filament-teams.

Installation

You can install the package via composer:

composer require jeffersongoncalves/laravel-teams

Publish and run the migrations:

php artisan vendor:publish --tag="teams-migrations"
php artisan migrate

Optionally publish the config file:

php artisan vendor:publish --tag="teams-config"

Usage

Add the HasTeams trait to your User model:

use Illuminate\Foundation\Auth\User as Authenticatable;
use JeffersonGoncalves\Teams\Concerns\HasTeams;

class User extends Authenticatable
{
    use HasTeams;
}

Make sure your users table has a nullable current_team_id column (the published migration adds it automatically).

Working with teams

$user->ownedTeams;          // Teams owned by the user
$user->teams;               // Teams the user belongs to
$user->currentTeam;         // The user's current team
$user->personalTeam();      // The user's personal team
$user->switchTeam($team);   // Switch the current team
$user->belongsToTeam($team);
$user->ownsTeam($team);

Invitations

use JeffersonGoncalves\Teams\Models\TeamInvitation;

$invitation = TeamInvitation::create([
    'team_id' => $team->id,
    'email' => 'invited@example.com',
]);

$invitation->accept($user); // Attaches the user and deletes the invitation

Configuration

The published config/teams.php file lets you customize the authentication guard, the user model, whether personal teams are created automatically, the Eloquent models, and the table names.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.