mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-17 03:44:06 +00:00
Manual mode improvements (use correct event type, add new listeners) (#1013)
* fix issue and add test * Update CreateTenantConnection.php * add purge call * Update ManualModeTest.php * use tenant connection and central connection listener * Update ManualModeTest.php * fix test * improvements * Update ManualModeTest.php * add comment * simplify comment Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
ea19117870
commit
73c5655bc8
4 changed files with 92 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ namespace Stancl\Tenancy\Listeners;
|
|||
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
use Stancl\Tenancy\Database\DatabaseManager;
|
||||
use Stancl\Tenancy\Events\Contracts\TenantEvent;
|
||||
use Stancl\Tenancy\Events\Contracts\TenancyEvent;
|
||||
|
||||
class CreateTenantConnection
|
||||
{
|
||||
|
|
@ -15,11 +15,12 @@ class CreateTenantConnection
|
|||
) {
|
||||
}
|
||||
|
||||
public function handle(TenantEvent $event): void
|
||||
public function handle(TenancyEvent $event): void
|
||||
{
|
||||
/** @var TenantWithDatabase */
|
||||
$tenant = $event->tenant;
|
||||
/** @var TenantWithDatabase $tenant */
|
||||
$tenant = $event->tenancy->tenant;
|
||||
|
||||
$this->database->purgeTenantConnection();
|
||||
$this->database->createTenantConnection($tenant);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue