validate($input); $cronJob = new CronJob([ 'server_id' => $server->id, 'user' => $input['user'], 'command' => $input['command'], 'frequency' => $input['frequency'], 'status' => CronjobStatus::CREATING, ]); $cronJob->save(); $cronJob->addToServer(); } /** * @throws ValidationException */ private function validate(array $input): void { Validator::make($input, [ 'command' => [ 'required', ], 'user' => [ 'required', 'in:root,'.config('core.ssh_user'), ], 'frequency' => [ 'required', new CronRule(), ], ])->validateWithBag('createCronJob'); } }