28 lines
493 B
PHP
28 lines
493 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Traits;
|
||
|
use App\Scopes\AddSiteId;
|
||
|
|
||
|
trait MultiTenant
|
||
|
{
|
||
|
/**
|
||
|
* The "booting" method of the model.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
protected static function boot()
|
||
|
{
|
||
|
parent::boot();
|
||
|
|
||
|
// Force our queries to include a site ID
|
||
|
static::addGlobalScope(new AddSiteId);
|
||
|
// Capture our inserts/deletes/updates to include a site ID
|
||
|
// @todo this is not yet complete
|
||
|
static::observe(new \App\MultiTenantObserver);
|
||
|
}
|
||
|
|
||
|
public function table() {
|
||
|
return $this->table;
|
||
|
}
|
||
|
}
|