File: /home/eslinced-103/brise-edu.or.kr/app/Jobs/CreateTenantAdmin.php
<?php
namespace App\Jobs;
use App\Models\Central\Tenant;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CreateTenantAdmin implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** @var Tenant */
protected $tenant;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Tenant $tenant)
{
$this->tenant = $tenant;
}
/**
* Execute the job.
*/
public function handle(): void
{
$this->tenant->run(function ($tenant) {
User::create(
$tenant->only(['name', 'email', 'password'])
);
$tenant->update([
'name' => '', // We don't need this anymore
'ready' => true,
]);
});
}
}