1
0
Fork 0
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:
Chris Brown 2019-10-17 13:25:30 -04:00 committed by Samuel Štancl
parent 3dbbbe8b24
commit d5b01219fd
4 changed files with 113 additions and 6 deletions

View 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);
}
}