mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 10:54:04 +00:00
CanDeleteKeys interface
This commit is contained in:
parent
bdab188a61
commit
c8e8c838db
6 changed files with 82 additions and 5 deletions
|
|
@ -9,8 +9,10 @@ use Closure;
|
|||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Traits\ForwardsCalls;
|
||||
use Stancl\Tenancy\Contracts\Future\CanDeleteKeys;
|
||||
use Stancl\Tenancy\Contracts\StorageDriver;
|
||||
use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
||||
use Stancl\Tenancy\Exceptions\NotImplementedException;
|
||||
use Stancl\Tenancy\Exceptions\TenantStorageException;
|
||||
|
||||
/**
|
||||
|
|
@ -349,6 +351,29 @@ class Tenant implements ArrayAccess
|
|||
return $this->put($key, $value);
|
||||
}
|
||||
|
||||
// todo also deleteKey()?
|
||||
|
||||
/**
|
||||
* Delete keys from the tenant's storage.
|
||||
*
|
||||
* @param string|string[] $keys
|
||||
* @return self
|
||||
*/
|
||||
public function deleteKeys($keys): self
|
||||
{
|
||||
$keys = (array) $keys;
|
||||
|
||||
if (! $this->storage instanceof CanDeleteKeys) {
|
||||
throw new NotImplementedException(get_class($this->storage), 'deleteMany',
|
||||
'This method was added to storage drivers provided by the package in 2.2.0 and will be part of the StorageDriver contract in 3.0.0.'
|
||||
);
|
||||
} else {
|
||||
$this->storage->deleteMany($keys);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue