mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
init
This commit is contained in:
35
app/Jobs/Database/CreateOnServer.php
Normal file
35
app/Jobs/Database/CreateOnServer.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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,
|
||||
]));
|
||||
}
|
||||
}
|
37
app/Jobs/Database/DeleteFromServer.php
Normal file
37
app/Jobs/Database/DeleteFromServer.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Database;
|
||||
|
||||
use App\Events\Broadcast;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Database;
|
||||
|
||||
class DeleteFromServer extends Job
|
||||
{
|
||||
protected Database $database;
|
||||
|
||||
public function __construct(Database $database)
|
||||
{
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->database->server->database()->handler()->delete($this->database->name);
|
||||
event(
|
||||
new Broadcast('delete-database-finished', [
|
||||
'id' => $this->database->id,
|
||||
])
|
||||
);
|
||||
$this->database->delete();
|
||||
}
|
||||
|
||||
public function failed(): void
|
||||
{
|
||||
event(
|
||||
new Broadcast('delete-database-failed', [
|
||||
'id' => $this->database->id,
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user