Skip to content

Commit

Permalink
Readme Fixes (#77)
Browse files Browse the repository at this point in the history
* Fixed Headlines and added Comma for easier copy & paste

* Missed one headline
  • Loading branch information
sschlein authored and mpociot committed Mar 31, 2017
1 parent 992c411 commit 186bd39
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Teamwork is the fastest and easiest method to add a User / Team association with
- [License](#license)

<a name="installation" />

## Installation

## For Laravel 5.4
Expand All @@ -56,13 +57,14 @@ Add the version you need to your composer.json. Then run `composer install` or `

Then in your `config/app.php` add

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

in the `providers` array.

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

<a name="configuration"/>

## Configuration

To publish Teamwork's configuration and migration files, run the `vendor:publish` command.
Expand All @@ -75,6 +77,7 @@ 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.

<a name="user-relation-to-team" />

### User relation to teams

Run the `migration` command, to generate all tables needed for Teamwork.
Expand All @@ -95,9 +98,11 @@ You will also notice that a new column `current_team_id` has been added to your
This column will define the Team, the user is currently assigned to.

<a name="models" />

### Models

<a name="team" />

#### Team

Create a Team model inside `app/Team.php` using the following example:
Expand All @@ -122,6 +127,7 @@ The `owner_id` is an optional attribute and is nullable in the database.
When extending TeamworkTeam, remember to change the `team_model` variable in `config/teamwork.php` to your new model. For instance: `'team_model' => App\Team::class`

<a name="user" />

#### User

Add the `UserHasTeams` trait to your existing User model:
Expand All @@ -146,6 +152,7 @@ composer dump-autoload
```

<a name="middleware">

### Middleware

If you would like to use the middleware to protect to current team owner then just add the middleware provider to your `app\Http\Kernel.php` file.
Expand Down Expand Up @@ -173,9 +180,11 @@ Now only if the authenticated user is the owner of the current team can access t
**And you are ready to go.**

<a name="usage" />

## Usage

<a name="scaffolding" />

### Scaffolding

The easiest way to give your new Laravel project Team abilities is by using the `make:teamwork` command.
Expand All @@ -197,6 +206,7 @@ Imagine it as a the `make:auth` command for Teamwork.
To get started, take a look at the new installed `/teams` route in your project.

<a name="basic-concepts" />

### Basic concepts

Let's start by creating two different Teams.
Expand Down Expand Up @@ -228,6 +238,7 @@ $user->teams()->attach($team->id); // id only
By using the `attachTeam` method, if the User has no Teams assigned, the `current_team_id` column will automatically be set.

<a name="know-my-teams" />

### Get to know my team(s)

The currently assigned Team of a user can be accessed through the `currentTeam` relation like this:
Expand All @@ -253,6 +264,7 @@ The `Team` model has access to these methods:
- `hasUser(User $user)` &mdash; Helper function to determine if a user is a teammember

<a name="team-owner" />

### Team owner

If you need to check if the User is a team owner (regardless of the current team) use the `isTeamOwner()` method on the User model.
Expand All @@ -276,6 +288,7 @@ if( Auth::user()->isOwnerOfTeam( $team ) )
The `isOwnerOfTeam` method also allows an array or id as team parameter.

<a name="switching-the-current-team" />

### Switching the current team

If your Users are members of multiple teams you might want to give them access to a `switch team` mechanic in some way.
Expand All @@ -298,6 +311,7 @@ try {
Just like the `isOwnerOfTeam` method, `switchTeam` accepts a Team object, array, id or null as a parameter.

<a name="inviting-others" />

### Inviting others

The best team is of no avail if you're the only team member.
Expand Down Expand Up @@ -355,6 +369,7 @@ if( !Teamwork::hasPendingInvite( $request->email, $request->team) )
```

<a name="accepting-invites" />

### Accepting invites

Once you invited other users to join your team, in order to accept the invitation use the `Teamwork` facade once again.
Expand All @@ -374,6 +389,7 @@ The `acceptInvite` method does two thing:
- Delete the invitation afterwards.

<a name="denying-invites" />

### Denying invites

Just like accepting invites:
Expand All @@ -390,6 +406,7 @@ if( $invite ) // valid token found
The `denyInvite` method is only responsible for deleting the invitation from the database.

<a name="events" />

### Attaching/Detaching/Invite Events

If you need to run additional processes after attaching/detaching a team from a user or inviting a user, you can Listen for these events:
Expand Down Expand Up @@ -499,6 +516,7 @@ class YourUserInvitedToTeamListener
```

<a name="scope" />

### Limit Models to current Team

If your models are somehow limited to the current team you will find yourself writing this query over and over again: `Model::where('team_id', auth()->user()->currentTeam->id)->get();`.
Expand All @@ -508,10 +526,8 @@ To automate this process, you can let your models use the `UsedByTeams` trait. T
**Note:**
> This assumes that the model has a field called `team_id`

#### Usage


```php
use Mpociot\Teamwork\Traits\UsedByTeams;

Expand All @@ -536,6 +552,7 @@ Task::allTeams()->get();


<a name="license" />

## License

Teamwork is free software distributed under the terms of the MIT license.
Expand Down

0 comments on commit 186bd39

Please sign in to comment.