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

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

messerli90/teamwork
===================

User to Team associations with invitation system for Laravel

0.2.0(5y ago)08MITPHPPHP ^7.1CI failing

Since Mar 11Pushed 5y agoCompare

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

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Teamwork -
==========

[](#teamwork--)

[![Latest Version on Packagist](https://camo.githubusercontent.com/30e4f04d693ad9dce6b7228196f0d35619ce552cd757543cb7b34dfe6e237752/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d65737365726c6939302f7465616d776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/messerli90/teamwork)[![Build Status](https://camo.githubusercontent.com/0c08cdaaed730d860aa8b33aeea133442dbd3f22f6a993a4074e06939e85c5fd/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d65737365726c6939302f7465616d776f726b2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/messerli90/teamwork)[![Quality Score](https://camo.githubusercontent.com/cfcabab9b5cb16b845f5e09aea993184aa53696988578162e99dc5a649ca3d26/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d65737365726c6939302f7465616d776f726b2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/messerli90/teamwork)[![Total Downloads](https://camo.githubusercontent.com/b7da3b8b3ac9c4c080533866396232e4e0bdefd7df64eaeb4472633e41143c59/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d65737365726c6939302f7465616d776f726b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/messerli90/teamwork)

Teamwork adds User - Team association with an invite system to your Laravel App

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

[](#installation)

You can install the package via composer:

```
composer require messerli90/teamwork
```

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

[](#configuration)

To publish Teamwork's configuration file, run:

```
php artisan vendor:publish --provider="Messerli90\Teamwork\TeamworkServiceProvider" --tag=config
```

This will create `config/teamwork.php`. The default configuration should work just fine for you, but if you need to change the table / model names you should do that here. The config also supplies an array of possible roles a teammember can have, which can be changed.

### Migrations

[](#migrations)

Run the `migration` command to generate all tables needed for Teamwork. **If your users or teams are not stored in `users` and `teams` tables be sure to modify the the `config/teamwork.php` configuration.**

```
php artisan migrate
```

After the migration, 2 new tables will be created:

- team\_user -- pivot table that stores a many-to-many relation between teams and their (users) members. Also includes a 'roles' column, defaults to: member.
- team\_invites -- stores pending invites between teams and email addresses.

Usage
-----

[](#usage)

### Teamwork Facade

[](#teamwork-facade)

You can invite a User to a Team either by passing the User model, or an email address

```
Teamwork::inviteToTeam($user, $team, callable $success)
```

Check if the given user or email address has a pending invite for the provided Team

```
Teamwork::hasPendingInvite($user, $team) // bool
```

Get instance of Invite model from accept / deny token

```
Teamwork::getInviteFromAcceptToken($token)
Teamwork::getInviteFromDenyToken($token)
```

Accept / Deny Invite

```
Teamwork::acceptInvite(TeamInvite $invite)
Teamwork::denyInvite(TeamInvite $invite)
```

### Team - HasMembers trait

[](#team---hasmembers-trait)

Create your own Team model and add the `HasMembers`. Trait adds relation for `invites`, `users`, `owner`.

```
