mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 23:42:34 +00:00
40 lines
1.1 KiB
PHP
Executable File
40 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\SSH\Services\Webserver;
|
|
|
|
use App\SSH\Services\AbstractService;
|
|
use Closure;
|
|
|
|
abstract class AbstractWebserver extends AbstractService implements Webserver
|
|
{
|
|
public function creationRules(array $input): array
|
|
{
|
|
return [
|
|
'name' => [
|
|
'required',
|
|
function (string $attribute, mixed $value, Closure $fail): void {
|
|
$webserverExists = $this->service->server->webserver();
|
|
if ($webserverExists) {
|
|
$fail('You already have a webserver service on the server.');
|
|
}
|
|
},
|
|
],
|
|
];
|
|
}
|
|
|
|
public function deletionRules(): array
|
|
{
|
|
return [
|
|
'service' => [
|
|
function (string $attribute, mixed $value, Closure $fail): void {
|
|
$hasSite = $this->service->server->sites()
|
|
->exists();
|
|
if ($hasSite) {
|
|
$fail('Cannot uninstall webserver while you have websites using it.');
|
|
}
|
|
},
|
|
],
|
|
];
|
|
}
|
|
}
|