moved company scope to trait
This commit is contained in:
parent
242706a3fb
commit
8515982cc7
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
use App\Scopes\Company;
|
|
||||||
use App\Traits\Tenants;
|
use App\Traits\Tenants;
|
||||||
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
@ -27,16 +26,6 @@ abstract class Model extends Eloquent
|
|||||||
parent::observe($classes);
|
parent::observe($classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The "booted" method of the model.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected static function booted()
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new Company);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global company relation.
|
* Global company relation.
|
||||||
*
|
*
|
||||||
|
@ -60,8 +60,6 @@ class Transaction extends Model
|
|||||||
*/
|
*/
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
parent::booted();
|
|
||||||
|
|
||||||
static::addGlobalScope(new Scope);
|
static::addGlobalScope(new Scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,6 @@ class Document extends Model
|
|||||||
*/
|
*/
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
parent::booted();
|
|
||||||
|
|
||||||
static::addGlobalScope(new Scope);
|
static::addGlobalScope(new Scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Models\Setting;
|
namespace App\Models\Setting;
|
||||||
|
|
||||||
use App\Scopes\Company;
|
|
||||||
use App\Traits\Tenants;
|
use App\Traits\Tenants;
|
||||||
use Illuminate\Database\Eloquent\Model as Eloquent;
|
use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||||
|
|
||||||
@ -23,16 +22,6 @@ class Setting extends Eloquent
|
|||||||
*/
|
*/
|
||||||
protected $fillable = ['company_id', 'key', 'value'];
|
protected $fillable = ['company_id', 'key', 'value'];
|
||||||
|
|
||||||
/**
|
|
||||||
* The "booted" method of the model.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected static function booted()
|
|
||||||
{
|
|
||||||
static::addGlobalScope(new Company);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function company()
|
public function company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Common\Company');
|
return $this->belongsTo('App\Models\Common\Company');
|
||||||
|
@ -2,8 +2,20 @@
|
|||||||
|
|
||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use App\Scopes\Company;
|
||||||
|
|
||||||
trait Tenants
|
trait Tenants
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The "booting" method of the model.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function bootTenants()
|
||||||
|
{
|
||||||
|
static::addGlobalScope(new Company);
|
||||||
|
}
|
||||||
|
|
||||||
public function isTenantable()
|
public function isTenantable()
|
||||||
{
|
{
|
||||||
return (isset($this->tenantable) && ($this->tenantable === true));
|
return (isset($this->tenantable) && ($this->tenantable === true));
|
||||||
|
@ -13,8 +13,6 @@ class Bill extends Document
|
|||||||
{
|
{
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
parent::booted();
|
|
||||||
|
|
||||||
static::addGlobalScope(new ReplaceDeprecatedColumns);
|
static::addGlobalScope(new ReplaceDeprecatedColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ class Invoice extends Document
|
|||||||
{
|
{
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
parent::booted();
|
|
||||||
|
|
||||||
static::addGlobalScope(new ReplaceDeprecatedColumns);
|
static::addGlobalScope(new ReplaceDeprecatedColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user