Download the PHP package ibrostudio/laravel-teamable without Composer
On this page you can find all versions of the php package ibrostudio/laravel-teamable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ibrostudio/laravel-teamable
More information about ibrostudio/laravel-teamable
Files in ibrostudio/laravel-teamable
Package laravel-teamable
Short Description Add team properties to Eloquent models
License MIT
Homepage https://github.com/ibrostudio/laravel-teamable
Informations about the package laravel-teamable
Laravel Teamable
Add team properties to Eloquent models.
Installation
Install the package via composer:
Then run the installer:
Usage
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.
Add the trait IBroStudio\Teamable\Concerns\HasTeams
to the Eloquent model that will define member of the 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:
You can disable automatic team creation by setting auto.create
to false in the teamable.php
configuration file.
To add team to an existing model:
Add member to a team
A user can be a member of multiple teams and different team types:
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.
To change the current team ID, use the switchToTeam
method:
Remove member from a 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
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-teamable with dependencies
ibrostudio/laravel-data-repository Version ^1.0
illuminate/contracts Version ^11.0
michael-rubel/laravel-value-objects Version ^7.0
spatie/laravel-package-tools Version ^1.14.0
spatie/laravel-sluggable Version ^3.5