AuraEQ/laravel-multi-tenant — pull request #13 by HipsterJazzbo (2014-09-15 21:52:36+00:00)
Title: Big Ol' Refactor

### Note

This needs tests. To be honest, I don't know enough about testing to write them, but I'm not super keen to merge this untested. If anyone is keen to write some, the laravel community would thank you profusely, if not monitarily. :beers:

## Deets

This is a big refactor, built on and replacing #10. A quick summary:

- Now using a Facade for `TenantScope`
- Renamed `ScopedByTenant` trait to `TenantScopedModelTrait`, to be more explicit
- Introduces `getTenantScope()` in model (can be useful to change it)
- Supports multiple tenants. Set tenant scope by using `addTenant($column, $id)` method (typically to be used in `app/filters.php`)
- Optional property `$tenantColumns` can be used on an Eloquent model to define which column(s) should be used to define tenants. A default is available in the config.
- Moved some code from `TenantScopedModelTrait` to `TenantScope`
- Maybe some other stuff? I'm bad at committing often.

This branch DOES NOT use the session class as discussed in #5. @geomagilles has pointed out that you ought to be able to call `addTenant()` in whatever place that you check for a valid login, probably in `app/filters.php`. Dur.