mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
- 2.x - sites (wip)
- improved ssh error handling - database soft deletes
This commit is contained in:
@ -70,7 +70,7 @@ public function storage(): BelongsTo
|
||||
|
||||
public function database(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Database::class);
|
||||
return $this->belongsTo(Database::class)->withTrashed();
|
||||
}
|
||||
|
||||
public function files(): HasMany
|
||||
|
@ -3,9 +3,11 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\DatabaseStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* @property int $server_id
|
||||
@ -13,10 +15,12 @@
|
||||
* @property string $status
|
||||
* @property Server $server
|
||||
* @property Backup[] $backups
|
||||
* @property Carbon $deleted_at
|
||||
*/
|
||||
class Database extends AbstractModel
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'server_id',
|
||||
@ -41,9 +45,6 @@ public static function boot(): void
|
||||
$user->save();
|
||||
}
|
||||
});
|
||||
$database->backups()->each(function (Backup $backup) {
|
||||
$backup->delete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -97,13 +97,17 @@ public function write($buf): void
|
||||
}
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
public function getContent($lines = null): ?string
|
||||
{
|
||||
if ($this->is_remote) {
|
||||
return $this->server->os()->tail($this->name, 150);
|
||||
return $this->server->os()->tail($this->name, $lines ?? 150);
|
||||
}
|
||||
|
||||
if (Storage::disk($this->disk)->exists($this->name)) {
|
||||
if ($lines) {
|
||||
return tail(Storage::disk($this->disk)->path($this->name), $lines);
|
||||
}
|
||||
|
||||
return Storage::disk($this->disk)->get($this->name);
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,21 @@ public static function boot(): void
|
||||
});
|
||||
}
|
||||
|
||||
public function isReady(): bool
|
||||
{
|
||||
return $this->status === SiteStatus::READY;
|
||||
}
|
||||
|
||||
public function isInstalling(): bool
|
||||
{
|
||||
return in_array($this->status, [SiteStatus::INSTALLING, SiteStatus::INSTALLATION_FAILED]);
|
||||
}
|
||||
|
||||
public function isInstallationFailed(): bool
|
||||
{
|
||||
return $this->status === SiteStatus::INSTALLATION_FAILED;
|
||||
}
|
||||
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
|
@ -15,6 +15,7 @@
|
||||
* @property ?string $url
|
||||
* @property string $access_token
|
||||
* @property ?int $project_id
|
||||
* @property string $image_url
|
||||
*/
|
||||
class SourceControl extends AbstractModel
|
||||
{
|
||||
@ -63,4 +64,9 @@ public static function getByProjectId(int $projectId): Builder
|
||||
->where('project_id', $projectId)
|
||||
->orWhereNull('project_id');
|
||||
}
|
||||
|
||||
public function getImageUrlAttribute(): string
|
||||
{
|
||||
return url('/static/images/'.$this->provider.'.svg');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user