diff --git a/app/Abstracts/Model.php b/app/Abstracts/Model.php index 93db8fd67..c6b0d77f5 100644 --- a/app/Abstracts/Model.php +++ b/app/Abstracts/Model.php @@ -2,7 +2,6 @@ namespace App\Abstracts; -use App\Scopes\Company; use App\Traits\Tenants; use GeneaLabs\LaravelModelCaching\Traits\Cachable; use Illuminate\Database\Eloquent\Model as Eloquent; @@ -27,16 +26,6 @@ abstract class Model extends Eloquent parent::observe($classes); } - /** - * The "booted" method of the model. - * - * @return void - */ - protected static function booted() - { - static::addGlobalScope(new Company); - } - /** * Global company relation. * diff --git a/app/Models/Banking/Transaction.php b/app/Models/Banking/Transaction.php index 5a893806a..d57ec6575 100644 --- a/app/Models/Banking/Transaction.php +++ b/app/Models/Banking/Transaction.php @@ -60,8 +60,6 @@ class Transaction extends Model */ protected static function booted() { - parent::booted(); - static::addGlobalScope(new Scope); } diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index dc351bc4c..45e56b088 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -80,8 +80,6 @@ class Document extends Model */ protected static function booted() { - parent::booted(); - static::addGlobalScope(new Scope); } diff --git a/app/Models/Setting/Setting.php b/app/Models/Setting/Setting.php index fee0d913c..c12ce0191 100644 --- a/app/Models/Setting/Setting.php +++ b/app/Models/Setting/Setting.php @@ -2,7 +2,6 @@ namespace App\Models\Setting; -use App\Scopes\Company; use App\Traits\Tenants; use Illuminate\Database\Eloquent\Model as Eloquent; @@ -23,16 +22,6 @@ class Setting extends Eloquent */ 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() { return $this->belongsTo('App\Models\Common\Company'); diff --git a/app/Traits/Tenants.php b/app/Traits/Tenants.php index a2dcf0960..8c11ea328 100644 --- a/app/Traits/Tenants.php +++ b/app/Traits/Tenants.php @@ -2,8 +2,20 @@ namespace App\Traits; +use App\Scopes\Company; + trait Tenants { + /** + * The "booting" method of the model. + * + * @return void + */ + protected static function bootTenants() + { + static::addGlobalScope(new Company); + } + public function isTenantable() { return (isset($this->tenantable) && ($this->tenantable === true)); diff --git a/modules/BC21/Models/Purchase/Bill.php b/modules/BC21/Models/Purchase/Bill.php index 739e10192..3a6c3dff5 100644 --- a/modules/BC21/Models/Purchase/Bill.php +++ b/modules/BC21/Models/Purchase/Bill.php @@ -13,8 +13,6 @@ class Bill extends Document { protected static function booted() { - parent::booted(); - static::addGlobalScope(new ReplaceDeprecatedColumns); } diff --git a/modules/BC21/Models/Sale/Invoice.php b/modules/BC21/Models/Sale/Invoice.php index 46ee75a15..bd7eb5f05 100644 --- a/modules/BC21/Models/Sale/Invoice.php +++ b/modules/BC21/Models/Sale/Invoice.php @@ -13,8 +13,6 @@ class Invoice extends Document { protected static function booted() { - parent::booted(); - static::addGlobalScope(new ReplaceDeprecatedColumns); }