PHPackages                             danielverissimo/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. danielverissimo/teamwork

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

danielverissimo/teamwork
========================

User to Team associations for the Laravel 5 Framework

5.0.0(9y ago)08MITPHPPHP &gt;=5.6.4

Since Jul 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/danielverissimo/teamwork)[ Packagist](https://packagist.org/packages/danielverissimo/teamwork)[ Docs](http://github.com/mpociot/teamwork)[ RSS](/packages/danielverissimo-teamwork/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (5)Versions (34)Used By (0)

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

[](#teamwork-laravel-5-package)

[![Latest Version](https://camo.githubusercontent.com/cc1d1c5316d621ee747659e2c3f960e6522089f0e9323b40ca3e0ce225d181b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d706f63696f742f7465616d776f726b2e737667)](https://github.com/mpociot/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 5** project.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Configuration](#configuration)
    - [User relation to teams](#user-relation-to-team)
    - [Models](#models)
        - [Team](#team)
        - [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 5.4
---------------

[](#for-laravel-54)

```
"mpociot/teamwork": "~5.0"

```

For Laravel 5.3
---------------

[](#for-laravel-53)

```
"mpociot/teamwork": "~4.0"

```

For Laravel 5.2
---------------

[](#for-laravel-52)

```
"mpociot/teamwork": "~3.0"

```

For Laravel 5.0 / 5.1
---------------------

[](#for-laravel-50--51)

```
"mpociot/teamwork": "~2.0"

```

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

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

Then in your `config/app.php` add

```
Mpociot\Teamwork\TeamworkServiceProvider::class,

```

in the `providers` array.

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)

#### Team

[](#team)

Create a Team model inside `app/Team.php` using the following example:

```
