akaunting/app/Traits/Tenants.php

31 lines
534 B
PHP
Raw Permalink Normal View History

2020-05-02 14:33:41 +03:00
<?php
namespace App\Traits;
2021-01-28 14:29:43 +03:00
use App\Scopes\Company;
2020-05-02 14:33:41 +03:00
trait Tenants
{
2021-01-28 14:29:43 +03:00
/**
* The "booting" method of the model.
*
* @return void
*/
protected static function bootTenants()
{
static::addGlobalScope(new Company);
}
2020-05-02 14:33:41 +03:00
public function isTenantable()
{
2022-06-01 10:15:55 +03:00
$tenantable = $this->tenantable ?? true;
2021-06-17 10:59:07 +03:00
return ($tenantable === true) && in_array('company_id', $this->getFillable());
2020-05-02 14:33:41 +03:00
}
public function isNotTenantable()
{
return !$this->isTenantable();
}
}