mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $site_id
|
||||
* @property int $mode
|
||||
* @property string $from
|
||||
* @property string $to
|
||||
* @property string $status
|
||||
*/
|
||||
class Redirect extends AbstractModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'site_id',
|
||||
'mode',
|
||||
'from',
|
||||
'to',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'site_id' => 'integer',
|
||||
'mode' => 'integer',
|
||||
];
|
||||
|
||||
public function site(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property string $content
|
||||
* @property User $creator
|
||||
*/
|
||||
class Script extends AbstractModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
'content',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function executions(): HasMany
|
||||
{
|
||||
return $this->hasMany(ScriptExecution::class, 'script_id');
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property int $script_id
|
||||
* @property int $server_id
|
||||
* @property string $user
|
||||
* @property Carbon $finished_at
|
||||
* @property ?Server $server
|
||||
* @property Script $script
|
||||
*/
|
||||
class ScriptExecution extends AbstractModel
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'script_id',
|
||||
'server_id',
|
||||
'user',
|
||||
'finished_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'script_id' => 'integer',
|
||||
'server_id' => 'integer',
|
||||
];
|
||||
|
||||
public function script(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Script::class);
|
||||
}
|
||||
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
}
|
@ -51,7 +51,6 @@
|
||||
* @property FirewallRule[] $firewallRules
|
||||
* @property CronJob[] $cronJobs
|
||||
* @property Queue[] $queues
|
||||
* @property ScriptExecution[] $scriptExecutions
|
||||
* @property Backup[] $backups
|
||||
* @property Queue[] $daemons
|
||||
* @property SshKey[] $sshKeys
|
||||
@ -121,7 +120,6 @@ public static function boot(): void
|
||||
$server->cronJobs()->delete();
|
||||
$server->queues()->delete();
|
||||
$server->daemons()->delete();
|
||||
$server->scriptExecutions()->delete();
|
||||
$server->sshKeys()->detach();
|
||||
if (File::exists($server->sshKey()['public_key_path'])) {
|
||||
File::delete($server->sshKey()['public_key_path']);
|
||||
@ -187,11 +185,6 @@ public function queues(): HasMany
|
||||
return $this->hasMany(Queue::class);
|
||||
}
|
||||
|
||||
public function scriptExecutions(): HasMany
|
||||
{
|
||||
return $this->hasMany(ScriptExecution::class);
|
||||
}
|
||||
|
||||
public function backups(): HasMany
|
||||
{
|
||||
return $this->hasMany(Backup::class);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@ -38,8 +39,12 @@ public static function boot(): void
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (ServerLog $log) {
|
||||
if (Storage::disk($log->disk)->exists($log->name)) {
|
||||
Storage::disk($log->disk)->delete($log->name);
|
||||
try {
|
||||
if (Storage::disk($log->disk)->exists($log->name)) {
|
||||
Storage::disk($log->disk)->delete($log->name);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $user_id
|
||||
@ -40,4 +41,9 @@ public function getCredentials(): array
|
||||
{
|
||||
return $this->credentials;
|
||||
}
|
||||
|
||||
public function servers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Server::class, 'provider_id');
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
* @property Deployment[] $deployments
|
||||
* @property ?GitHook $gitHook
|
||||
* @property DeploymentScript $deploymentScript
|
||||
* @property Redirect[] $redirects
|
||||
* @property Queue[] $queues
|
||||
* @property Ssl[] $ssls
|
||||
* @property ?Ssl $activeSsl
|
||||
@ -76,7 +75,6 @@ public static function boot(): void
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (Site $site) {
|
||||
$site->redirects()->delete();
|
||||
$site->queues()->delete();
|
||||
$site->ssls()->delete();
|
||||
$site->deployments()->delete();
|
||||
@ -116,11 +114,6 @@ public function deploymentScript(): HasOne
|
||||
return $this->hasOne(DeploymentScript::class);
|
||||
}
|
||||
|
||||
public function redirects(): HasMany
|
||||
{
|
||||
return $this->hasMany(Redirect::class);
|
||||
}
|
||||
|
||||
public function queues(): HasMany
|
||||
{
|
||||
return $this->hasMany(Queue::class);
|
||||
@ -192,8 +185,8 @@ public function php(): ?Service
|
||||
|
||||
public function changePHPVersion($version): void
|
||||
{
|
||||
$this->php_version = $version;
|
||||
$this->server->webserver()->handler()->changePHPVersion($this, $version);
|
||||
$this->php_version = $version;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use App\SourceControlProviders\SourceControlProvider;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property string $provider
|
||||
@ -37,4 +38,9 @@ public function getRepo(?string $repo = null): ?array
|
||||
{
|
||||
return $this->provider()->getRepo($repo);
|
||||
}
|
||||
|
||||
public function sites(): HasMany
|
||||
{
|
||||
return $this->hasMany(Site::class);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $user_id
|
||||
@ -39,4 +40,9 @@ public function provider(): \App\StorageProviders\StorageProvider
|
||||
|
||||
return new $providerClass($this);
|
||||
}
|
||||
|
||||
public function backups(): HasMany
|
||||
{
|
||||
return $this->hasMany(Backup::class, 'storage_id');
|
||||
}
|
||||
}
|
||||
|
@ -86,11 +86,6 @@ public function serverProviders(): HasMany
|
||||
return $this->hasMany(ServerProvider::class);
|
||||
}
|
||||
|
||||
public function scripts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Script::class, 'user_id');
|
||||
}
|
||||
|
||||
public function sourceControl(string $provider): HasOne
|
||||
{
|
||||
return $this->hasOne(SourceControl::class)->where('provider', $provider);
|
||||
|
Reference in New Issue
Block a user