Aller au contenu
← Retour aux projets

FilaTeams

#FilaTeams

Team management plugin for Filament 5. This is the exact implementation of Laravel 13 Starter Kit Teams functionality, just in Filament.

Adds full team functionality — creating teams, switching between them, inviting members, managing roles — wired into Filament's panel with zero configuration on your part.


#Package Demo

Here's a 7-minute YouTube video with package demo.

For reference, I also have a 33-minute video course on Laravel 13 Teams customizations.


#Screenshots




#Requirements

  • PHP 8.2+
  • Laravel 12 or 13
  • Filament 5

This package is designed to be installed on a fresh Filament project, right after filament:install --panels. It creates its own database tables and takes over the panel's tenancy system, so it's best to set it up before building your resources and pages on top.


#Installation

#1. Install via Composer

composer require laraveldaily/filateams

#2. Update your User model

Add the HasTeamMembership interface and HasTeams trait:

use LaravelDaily\FilaTeams\Concerns\HasTeams;
use LaravelDaily\FilaTeams\Contracts\HasTeamMembership;

class User extends Authenticatable implements HasTeamMembership
{
    use HasTeams;

    // ... rest of your model
}

#3. Register the plugin in your PanelProvider

use LaravelDaily\FilaTeams\FilaTeamsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... your existing config
        ->registration() // enable if not already
        ->plugin(FilaTeamsPlugin::make());
}

#4. Run migrations

php artisan migrate

That's it. No additional configuration needed.


#What you get

  • Automatic personal team — when a user registers, a personal team ("{name}'s Team") is created automatically
  • Team switcher — Filament's built-in tenant switcher lets users switch between their teams
  • Create team — available at /admin/new
  • Team settings page — at /admin/{team}/settings, with sections for:
    • Updating team name
    • Managing members (change roles, remove members, leave team)
    • Inviting new members by email
    • Deleting the team (non-personal teams only, owner only)
  • Email invitations — invited users receive an email with an accept link
  • Role-based permissions — Owner, Admin, and Member roles with granular permissions

#Roles & Permissions

Permission Owner Admin Member
Update team name Yes Yes -
Delete team Yes - -
Add/remove members Yes - -
Change member roles Yes - -
Create invitations Yes Yes -
Cancel invitations Yes Yes -

The built-in roles and permissions can be replaced entirely. Publish the config and point enums.role and enums.permission to your own string-backed enum classes that implement TeamRoleContract and TeamPermissionContract:

// config/filateams.php
'enums' => [
    'role'       => App\Enums\MyTeamRole::class,
    'permission' => App\Enums\MyTeamPermission::class,
],

See src/Contracts/TeamRoleContract.php for the full interface your custom role enum must satisfy.


#Invitation flow

  1. An Owner or Admin invites a user by email from the team settings page
  2. The invited user receives an email with an accept link
  3. If they're logged in and the email matches — they're added to the team immediately
  4. If they're not logged in — they're redirected to login first, then back to accept
  5. Invitations expire after 7 days (configurable)

#For existing users

If you install the package on a project that already has users, those users won't have teams yet. Create personal teams for them:

use App\Models\User;
use LaravelDaily\FilaTeams\Actions\CreateTeam;

$action = new CreateTeam;

User::whereDoesntHave('teams')->each(function ($user) use ($action) {
    $action->handle($user, [
        'name' => $user->name . "'s Team",
        'is_personal' => true,
    ]);
});

You can run this in tinker or in a seeder/migration.


#Configuration

Publish the config file:

php artisan vendor:publish --tag=filateams-config

This creates config/filateams.php:

return [
    // Override the role and permission enum classes
    'enums' => [
        'role'       => LaravelDaily\FilaTeams\Enums\TeamRole::class,
        'permission' => LaravelDaily\FilaTeams\Enums\TeamPermission::class,
    ],

    // Override model classes if you need to extend them
    'models' => [
        'team'       => LaravelDaily\FilaTeams\Models\Team::class,
        'membership' => LaravelDaily\FilaTeams\Models\Membership::class,
        'invitation' => LaravelDaily\FilaTeams\Models\TeamInvitation::class,
    ],

    // How long invitations are valid
    'invitation' => [
        'expires_after_days' => 7,
    ],

    // Create a personal team when a user registers
    'create_personal_team_on_registration' => true,
];

#Translations

To publish the language files to your application:

php artisan vendor:publish --tag=filateams-translations

This copies the files to lang/vendor/filateams/ where you can modify existing translations or add new languages by creating a folder named after the locale (e.g. lang/vendor/filateams/de/filateams.php).


#Database schema

The package creates three tables and adds one column:

teamsid, name, slug (unique), is_personal, timestamps, soft_deletes

team_membersid, team_id, user_id, role, timestamps (unique on team_id + user_id)

team_invitationsid, code (unique, 64 chars), team_id, email, role, invited_by, expires_at, accepted_at, timestamps

users — adds current_team_id (nullable foreign key to teams)

This schema matches the Laravel 13 starter kit exactly.


#License

MIT

Nouvelle version disponible.