jeffersongoncalves/laravel-teams
Composer 安装命令:
composer require jeffersongoncalves/laravel-teams
包简介
A Laravel package that adds Teams, memberships, and team invitations with multi-tenancy support to your application.
README 文档
README
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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-24