mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 19:24:03 +00:00
Add event prevents, Tenant facade
This commit is contained in:
parent
1a88cad4d6
commit
4aa35322da
9 changed files with 187 additions and 97 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Stancl\Tenancy\Traits;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
trait TenantManagerEvents
|
||||
{
|
||||
/**
|
||||
|
|
@ -67,4 +69,17 @@ trait TenantManagerEvents
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an event.
|
||||
*
|
||||
* @param string $name Event name
|
||||
* @return Collection Prevented events
|
||||
*/
|
||||
public function event(string $name): Collection
|
||||
{
|
||||
return array_reduce($this->listeners[$name], function ($prevents, $listener) {
|
||||
return $prevents->merge($listener($this));
|
||||
}, collect([]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue