PHPackages                             oliuz/teamwork - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. oliuz/teamwork

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

oliuz/teamwork
==============

User to Team associations for the Laravel Framework

9.0.0(4y ago)3914.5k11[1 PRs](https://github.com/oliuz/teamwork/pulls)1MITPHPPHP ^7.4|^8.0.2CI failing

Since Apr 23Pushed 4y ago1 watchersCompare

[ Source](https://github.com/oliuz/teamwork)[ Packagist](https://packagist.org/packages/oliuz/teamwork)[ Docs](http://github.com/oliuz/teamwork)[ RSS](/packages/oliuz-teamwork/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)Dependencies (5)Versions (10)Used By (1)

Teamwork (Laravel Package)
==========================

[](#teamwork-laravel-package)

[![Latest Version](https://camo.githubusercontent.com/9a9ba202a9b7db9ce6a4f692348448e0eb0be1d72447d06a54e642d3229bc43d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6c69757a2f7465616d776f726b2e737667)](https://github.com/oliuz/teamwork/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/0ca5520aea5843df1dcbe8de09a88264075da1776a1ddc4f68524f7268a9560c/68747470733a2f2f7472617669732d63692e6f72672f6d706f63696f742f7465616d776f726b2e737667)](https://travis-ci.org/mpociot/teamwork)[![codecov.io](https://camo.githubusercontent.com/092a2f19a99ccc2d9003a46737fdcc3ea9424d67881d570ce76b0ff88d23a50f/68747470733a2f2f636f6465636f762e696f2f6769746875622f6d706f63696f742f7465616d776f726b2f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/mpociot/teamwork?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/c41ab05f2e10d3f16bd7d161548d60e1cbfb9fa88a544d1cbb9bd2cb2814d305/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61326132366535352d626663372d343961392d393333622d3732636137633234353033342f6d696e692e706e67)](https://insight.sensiolabs.com/projects/a2a26e55-bfc7-49a9-933b-72ca7c245034)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6a4fa89ae067cd4bd0e99522e1ef3b88103f252e144ed3cd612c3eff875e6397/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d706f63696f742f7465616d776f726b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mpociot/teamwork/?branch=master)

Teamwork is the fastest and easiest method to add a User / Team association with Invites to your **Laravel** project.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Configuration](#configuration)
    - [User relation to teams](#user-relation-to-team)
    - [Models](#models)
        - [User](#user)
- [Usage](#usage)
    - [Scaffoling](#scaffolding)
    - [Basic concepts](#basic-concepts)
    - [Get to know my team(s)](#know-my-teams)
    - [Team owner](#team-owner)
    - [Switching the current team](#switching-the-current-team)
    - [Inviting others](#inviting-others)
    - [Accepting invites](#accepting-invites)
    - [Denying invites](#denying-invites)
    - [Attach/Detach/Invite Events](#events)
    - [Limit Models to current Team](#scope)
- [License](#license)

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

[](#installation)

For Laravel ^8.0|^9.0
---------------------

[](#for-laravel-8090)

```
"oliuz/teamwork": "^9.0"

```

Add the version you need to your composer.json. Then run `composer install` or `composer update`.

(or run `composer require oliuz/teamwork` if you prefere that)

The `Teamwork` Facade will be installed automatically within the Service Provider.

Configuration
-------------

[](#configuration)

To publish Teamwork's configuration and migration files, run the `vendor:publish` command.

```
php artisan vendor:publish --provider="Mpociot\Teamwork\TeamworkServiceProvider"
```

This will create a `teamwork.php` in your config directory. The default configuration should work just fine for you, but you can take a look at it, if you want to customize the table / model names Teamwork will use.

### User relation to teams

[](#user-relation-to-teams)

Run the `migration` command, to generate all tables needed for Teamwork. **If your users are stored in a different table other than `users` be sure to modify the published migration.**

```
php artisan migrate
```

After the migration, 3 new tables will be created:

- teams — stores team records
- team\_user — stores [many-to-many](http://laravel.com/docs/5.1/eloquent-relationships#many-to-many) relations between users and teams
- team\_invites — stores pending invites for email addresses to teams

You will also notice that a new column `current_team_id` has been added to your users table. This column will define the Team, the user is currently assigned to.

### Models

[](#models)

#### User

[](#user)

Add the `UserHasTeams` trait to your existing User model:

```
