PHPackages                             ibrostudio/laravel-teamable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ibrostudio/laravel-teamable

ActiveLibrary

ibrostudio/laravel-teamable
===========================

Add team properties to Eloquent models

v1.0.0(1y ago)040MITPHPPHP ^8.2

Since Jun 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/iBroStudio/laravel-teamable)[ Packagist](https://packagist.org/packages/ibrostudio/laravel-teamable)[ Docs](https://github.com/ibrostudio/laravel-teamable)[ RSS](/packages/ibrostudio-laravel-teamable/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (15)Versions (2)Used By (0)

Laravel Teamable
================

[](#laravel-teamable)

Add team properties to Eloquent models.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require ibrostudio/laravel-teamable
```

Then run the installer:

```
php artisan data-repository:install
```

Usage
-----

[](#usage)

### Configuration

[](#configuration)

Add the trait `IBroStudio\Teamable\Concerns\IsTeamable` and the interface `\IBroStudio\Teamable\Contracts\Teamable` to the Eloquent model which must be a team.

**You can define many models as a team according to your needs.**

```
namespace App\Models;

use IBroStudio\Teamable\Concerns\IsTeamable;
use Illuminate\Database\Eloquent\Model;

class Company extends Model implements \IBroStudio\Teamable\Contracts\Teamable
{
    use IsTeamable;
}
```

Add the trait `IBroStudio\Teamable\Concerns\HasTeams` to the Eloquent model that will define member of the team.

```
namespace App\Models;

use IBroStudio\Teamable\Concerns\HasTeams;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasTeams;
}
```

### Creating team

[](#creating-team)

When you create a model that has the `IBroStudio\Teamable\Concerns\IsTeamable` trait, a `IBroStudio\Teamable\Models\Team` model is automatically created using the model's property defined in the `teamable.php` config file as the team name.

The default model property used is `name`. If your model does not have name, you can set another property to use in the `teamable.php` configuration file:

```
'model_name_attribute' => [
    'default' => 'name',
    Company::class => 'company_name'
],
```

You can disable automatic team creation by setting `auto.create` to false in the `teamable.php` configuration file.

```
$company = Company::create([
    'name' => 'iBroStudio',
]);

$company->team; // This give access to the team model through a MorphOne relationship
```

To add team to an existing model:

```
$company->createTeam();

$company->team; // This give access to the team model
```

### Add member to a team

[](#add-member-to-a-team)

```
$user->attachTeam($company->team);
```

A user can be a member of multiple teams and different team types:

```
$user->attachTeam($company_1->team);
$user->attachTeam($company_2->team);

$department = Department::create([
    'name' => 'Development',
]);
$user->attachTeam($department->team);
```

### Current team ID

[](#current-team-id)

For ease of use, a **current team ID** property is stored in a data repository for each team type.

When you add a member to a team, the value is set to that team's ID.

You can retrieve the value with the `getCurrentTeamId(TeamType $teamType)`method.

```
$user->getCurrentTeamId(TeamType::make(Company::class));
// or $user->getCurrentTeamId($company_1->team->type);

$user->getCurrentTeamId(TeamType::make(Department::class));
```

To change the current team ID, use the `switchToTeam` method:

```
$user->switchToTeam($company_2->team);
```

### Remove member from a team

[](#remove-member-from-a-team)

```
$user->detachTeam($company->team);
```

### Deleting team

[](#deleting-team)

Team model is automatically deleted when you delete the model that has the `IBroStudio\Teamable\Concerns\IsTeamable` trait.

You can disable automatic team deletion by setting `auto.delete` to false in the `teamable.php` configuration file.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

690d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a456dae716df4be38cb7d5f02ca522a02ec37eda586ab0cae0f504516b7c1ef?d=identicon)[iBroStudio](/maintainers/iBroStudio)

---

Top Contributors

[![Yann-iBroStudio](https://avatars.githubusercontent.com/u/2676572?v=4)](https://github.com/Yann-iBroStudio "Yann-iBroStudio (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laraveliBroStudiolaravel-teamable

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ibrostudio-laravel-teamable/health.svg)

```
[![Health](https://phpackages.com/badges/ibrostudio-laravel-teamable/health.svg)](https://phpackages.com/packages/ibrostudio-laravel-teamable)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
