mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 08:44:03 +00:00
[2.x] Allow automatic seeding after automatic migrations (#160)
This commit is contained in:
parent
3dbbbe8b24
commit
d5b01219fd
4 changed files with 113 additions and 6 deletions
42
src/Jobs/QueuedTenantDatabaseSeeder.php
Normal file
42
src/Jobs/QueuedTenantDatabaseSeeder.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
class QueuedTenantDatabaseSeeder implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var string */
|
||||
protected $tenantId;
|
||||
|
||||
/** @var array */
|
||||
protected $seederParameters = [];
|
||||
|
||||
public function __construct(Tenant $tenant, $seederParameters = [])
|
||||
{
|
||||
$this->tenantId = $tenant->id;
|
||||
$this->seederParameters = $seederParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Artisan::call('tenants:seed', [
|
||||
'--tenants' => [$this->tenantId],
|
||||
] + $this->seederParameters);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue