mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 09:34:05 +00:00
misc improvements - stronger types, exception refactor
This commit is contained in:
parent
ddc7cf49c3
commit
55d0a9ab87
34 changed files with 179 additions and 209 deletions
|
|
@ -35,10 +35,8 @@ class ImpersonationToken extends Model
|
|||
'created_at',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
public static function booted()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
$model->created_at = $model->created_at ?? $model->freshTimestamp();
|
||||
$model->token = $model->token ?? Str::random(128);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Tenant extends Model implements Contracts\Tenant
|
|||
return 'id';
|
||||
}
|
||||
|
||||
public function getTenantKey()
|
||||
public function getTenantKey(): int|string
|
||||
{
|
||||
return $this->getAttribute($this->getTenantKeyName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,8 @@ use Stancl\Tenancy\Contracts\Syncable;
|
|||
|
||||
class TenantPivot extends Pivot
|
||||
{
|
||||
public static function boot()
|
||||
public static function booted()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::saved(function (self $pivot) {
|
||||
$parent = $pivot->pivotParent;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue