mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 13:54:03 +00:00
Create listener for manual mode multi-db
This commit is contained in:
parent
b2c240a9f0
commit
d8563ba7e9
1 changed files with 22 additions and 0 deletions
22
src/Listeners/CreateTenantConnection.php
Normal file
22
src/Listeners/CreateTenantConnection.php
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Stancl\Tenancy\Listeners;
|
||||||
|
|
||||||
|
use Stancl\Tenancy\Database\DatabaseManager;
|
||||||
|
use Stancl\Tenancy\Events\Contracts\TenantEvent;
|
||||||
|
|
||||||
|
class CreateTenantConnection
|
||||||
|
{
|
||||||
|
/** @var DatabaseManager */
|
||||||
|
protected $database;
|
||||||
|
|
||||||
|
public function __construct(DatabaseManager $database)
|
||||||
|
{
|
||||||
|
$this->database = $database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(TenantEvent $event)
|
||||||
|
{
|
||||||
|
$this->database->createTenantConnection($event->tenant);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue