mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
@ -2,12 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @property int $site_id
|
||||
@ -52,11 +48,6 @@ public function sourceControl(): BelongsTo
|
||||
return $this->belongsTo(SourceControl::class);
|
||||
}
|
||||
|
||||
public function scopeHasEvent(Builder $query, string $event): Builder
|
||||
{
|
||||
return $query->where('events', 'like', "%\"{$event}\"%");
|
||||
}
|
||||
|
||||
public function deployHook(): void
|
||||
{
|
||||
$this->update(
|
||||
@ -64,19 +55,9 @@ public function deployHook(): void
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function destroyHook(): void
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$this->sourceControl->provider()->destroyHook($this->site->repository, $this->hook_id);
|
||||
$this->delete();
|
||||
DB::commit();
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
throw $e;
|
||||
}
|
||||
$this->sourceControl->provider()->destroyHook($this->site->repository, $this->hook_id);
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user