mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 23:54:03 +00:00
Make database creation queueable (#17)
* SOLIDify database creation * Return the result of fclose in SQLiteDBCreator * Make database creation queueable * Add DatabaseCreationTest * Make comment more descriptive [ci skip] * Add composer script to copy .env.example to .env * Minor tweaks * Fix env section * Fix DB_PASSWORD for Travis
This commit is contained in:
parent
136862369d
commit
c53a05cff4
13 changed files with 186 additions and 24 deletions
38
src/Jobs/QueuedDatabaseCreator.php
Normal file
38
src/Jobs/QueuedDatabaseCreator.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Stancl\Tenancy\Interfaces\DatabaseCreator;
|
||||
|
||||
class QueuedDatabaseCreator implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param DatabaseCreator $databaseCreator
|
||||
* @param string $databaseName
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DatabaseCreator $databaseCreator, string $databaseName)
|
||||
{
|
||||
$this->databaseCreator = $databaseCreator;
|
||||
$this->databaseName = $databaseName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->databaseCreator->createDatabase($databaseName);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue