mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 19:01:37 +00:00
36 lines
805 B
PHP
36 lines
805 B
PHP
<?php
|
|
|
|
namespace App\Jobs\Database;
|
|
|
|
use App\Enums\DatabaseStatus;
|
|
use App\Events\Broadcast;
|
|
use App\Jobs\Job;
|
|
use App\Models\Database;
|
|
|
|
class CreateOnServer extends Job
|
|
{
|
|
protected Database $database;
|
|
|
|
public function __construct(Database $database)
|
|
{
|
|
$this->database = $database;
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
$this->database->server->database()->handler()->create($this->database->name);
|
|
$this->database->status = DatabaseStatus::READY;
|
|
$this->database->save();
|
|
event(new Broadcast('create-database-finished', [
|
|
'id' => $this->database->id,
|
|
]));
|
|
}
|
|
|
|
public function failed(): void
|
|
{
|
|
event(new Broadcast('create-database-failed', [
|
|
'id' => $this->database->id,
|
|
]));
|
|
}
|
|
}
|