Akaunting/app/Traits/Tenants.php

31 lines
534 B
PHP
Raw Permalink Normal View History

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