1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 11:14:04 +00:00

remove HasDataColumn trait

This commit is contained in:
Samuel Štancl 2022-10-25 18:04:13 +02:00
parent 8c34640948
commit 648acc48c7
2 changed files with 9 additions and 20 deletions

View file

@ -1,15 +0,0 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Database\Concerns;
use Stancl\VirtualColumn\VirtualColumn;
/**
* Extends VirtualColumn for backwards compatibility. This trait will be removed in v4.
*/
trait HasDataColumn
{
use VirtualColumn;
}

View file

@ -11,6 +11,7 @@ use Stancl\Tenancy\Database\Concerns;
use Stancl\Tenancy\Database\TenantCollection;
use Stancl\Tenancy\Events;
use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
use Stancl\VirtualColumn\VirtualColumn;
/**
* @property string|int $id
@ -22,18 +23,16 @@ use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
*/
class Tenant extends Model implements Contracts\Tenant
{
use Concerns\CentralConnection,
use VirtualColumn,
Concerns\CentralConnection,
Concerns\GeneratesIds,
Concerns\HasDataColumn,
Concerns\HasInternalKeys,
Concerns\TenantRun,
Concerns\InitializationHelpers,
Concerns\InvalidatesResolverCache;
protected $table = 'tenants';
protected $primaryKey = 'id';
protected $guarded = [];
public function getTenantKeyName(): string
@ -46,12 +45,17 @@ class Tenant extends Model implements Contracts\Tenant
return $this->getAttribute($this->getTenantKeyName());
}
/** Get the current tenant. */
public static function current(): static|null
{
return tenant();
}
/** @throws TenancyNotInitializedException */
/**
* Get the current tenant or throw an exception if tenancy is not initialized.
*
* @throws TenancyNotInitializedException
*/
public static function currentOrFail(): static
{
return static::current() ?? throw new TenancyNotInitializedException;