mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
- 2.x - sites finishing
This commit is contained in:
@ -4,10 +4,10 @@
|
||||
|
||||
use App\Enums\SslStatus;
|
||||
use App\Enums\SslType;
|
||||
use App\Models\ServerLog;
|
||||
use App\Models\Site;
|
||||
use App\Models\Ssl;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
@ -18,7 +18,10 @@ class CreateSSL
|
||||
*/
|
||||
public function create(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
$site->ssls()
|
||||
->where('type', $input['type'])
|
||||
->where('status', SslStatus::FAILED)
|
||||
->delete();
|
||||
|
||||
$ssl = new Ssl([
|
||||
'site_id' => $site->id,
|
||||
@ -32,6 +35,7 @@ public function create(Site $site, array $input): void
|
||||
if (isset($input['aliases']) && $input['aliases']) {
|
||||
$ssl->domains = array_merge($ssl->domains, $site->aliases);
|
||||
}
|
||||
$ssl->log_id = ServerLog::log($site->server, 'create-ssl', '', $site)->id;
|
||||
$ssl->save();
|
||||
|
||||
dispatch(function () use ($site, $ssl) {
|
||||
@ -47,10 +51,7 @@ public function create(Site $site, array $input): void
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validate(array $input): void
|
||||
public static function rules(array $input): array
|
||||
{
|
||||
$rules = [
|
||||
'type' => [
|
||||
@ -61,9 +62,13 @@ protected function validate(array $input): void
|
||||
if (isset($input['type']) && $input['type'] == SslType::CUSTOM) {
|
||||
$rules['certificate'] = 'required';
|
||||
$rules['private'] = 'required';
|
||||
$rules['expires_at'] = 'required|date_format:Y-m-d|after_or_equal:'.now();
|
||||
$rules['expires_at'] = [
|
||||
'required',
|
||||
'date_format:Y-m-d',
|
||||
'after_or_equal:'.now(),
|
||||
];
|
||||
}
|
||||
|
||||
Validator::make($input, $rules)->validate();
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user