mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Migrate to HTMX (#114)
Dropped Livewire Added HTMX Added Blade code lint Drop Mysql and Redis Migrate to SQLite
This commit is contained in:
@ -4,16 +4,17 @@
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UninstallPHP
|
||||
{
|
||||
public function uninstall(Server $server, string $version): void
|
||||
public function uninstall(Server $server, array $input): void
|
||||
{
|
||||
$this->validate($server, $version);
|
||||
$this->validate($server, $input);
|
||||
|
||||
/** @var Service $php */
|
||||
$php = $server->services()->where('type', 'php')->where('version', $version)->first();
|
||||
$php = $server->php($input['version']);
|
||||
|
||||
$php->uninstall();
|
||||
}
|
||||
@ -21,17 +22,19 @@ public function uninstall(Server $server, string $version): void
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(Server $server, string $version): void
|
||||
private function validate(Server $server, array $input): void
|
||||
{
|
||||
$php = $server->services()->where('type', 'php')->where('version', $version)->first();
|
||||
Validator::make($input, [
|
||||
'version' => 'required|string',
|
||||
])->validate();
|
||||
|
||||
if (! $php) {
|
||||
if (! in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version has not been installed yet!')]
|
||||
['version' => __('This version is not installed')]
|
||||
);
|
||||
}
|
||||
|
||||
$hasSite = $server->sites()->where('php_version', $version)->first();
|
||||
$hasSite = $server->sites()->where('php_version', $input['version'])->first();
|
||||
if ($hasSite) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('Cannot uninstall this version because some sites are using it!')]
|
||||
|
Reference in New Issue
Block a user