Plugins base (#613)

* wip

* wip

* cleanup

* notification channels

* phpstan

* services

* remove server types

* refactoring

* refactoring
This commit is contained in:
Saeed Vaziry
2025-06-14 14:35:18 +02:00
committed by GitHub
parent adc0653d15
commit 131b828807
311 changed files with 3976 additions and 2660 deletions

View File

@ -3,11 +3,10 @@
namespace App\Actions\Worker;
use App\Enums\WorkerStatus;
use App\Models\Server;
use App\Models\Service;
use App\Models\Site;
use App\Models\Worker;
use App\SSH\Services\ProcessManager\ProcessManager;
use App\Services\ProcessManager\ProcessManager;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
@ -21,9 +20,10 @@ class EditWorker
*/
public function edit(Worker $worker, array $input): void
{
Validator::make($input, self::rules($worker->server, $worker->site))->validate();
Validator::make($input, self::rules($worker, $worker->site))->validate();
$worker->fill([
'name' => $input['name'],
'command' => $input['command'],
'user' => $input['user'],
'auto_start' => $input['auto_start'] ? 1 : 0,
@ -61,15 +61,29 @@ public function edit(Worker $worker, array $input): void
/**
* @return array<string, array<string>>
*/
public static function rules(Server $server, ?Site $site = null): array
public static function rules(Worker $worker, ?Site $site = null): array
{
return [
'name' => [
'required',
'string',
'max:255',
Rule::unique('workers')->where(function ($query) use ($worker, $site) {
return $query->where('server_id', $worker->server_id)
->where(function ($query) use ($site) {
if ($site) {
$query->where('site_id', $site->id);
}
});
})
->ignore($worker->id),
],
'command' => [
'required',
],
'user' => [
'required',
Rule::in($site?->getSshUsers() ?? $server->getSshUsers()),
Rule::in($site?->getSshUsers() ?? $worker->server->getSshUsers()),
],
'numprocs' => [
'required',