This commit is contained in:
Saeed Vaziry
2024-03-24 09:56:34 +01:00
committed by GitHub
parent 884f18db63
commit 4d051330d6
1055 changed files with 14493 additions and 20278 deletions

View File

@ -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();
}
}