mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:54:03 +00:00
Tenant::with
This commit is contained in:
parent
61cc0d9364
commit
93fc961b34
2 changed files with 28 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ namespace Stancl\Tenancy;
|
|||
|
||||
use ArrayAccess;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Str;
|
||||
use Stancl\Tenancy\Contracts\StorageDriver;
|
||||
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
||||
use Stancl\Tenancy\Exceptions\TenantStorageException;
|
||||
|
|
@ -267,6 +268,13 @@ class Tenant implements ArrayAccess
|
|||
return $this->put($key, $value);
|
||||
}
|
||||
|
||||
public function with(string $key, $value): self
|
||||
{
|
||||
$this->data[$key] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->get($key);
|
||||
|
|
@ -280,8 +288,12 @@ class Tenant implements ArrayAccess
|
|||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
public function __call($name, $arguments)
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
// todo withId()
|
||||
if (Str::startsWith($method, 'with')) {
|
||||
return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
|
||||
}
|
||||
|
||||
// todo throw some exception?
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue