initial commit
This commit is contained in:
28
app/Http/Requests/UpdateVmRequest.php
Normal file
28
app/Http/Requests/UpdateVmRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateVmRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user()->can('update', $this->route('vm'));
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['sometimes', 'string', 'max:100', 'regex:/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/'],
|
||||
'cpu' => ['sometimes', 'integer', 'min:1', 'max:32'],
|
||||
'ram' => ['sometimes', 'integer', 'min:512', 'max:131072'],
|
||||
'disk' => ['sometimes', 'integer', 'min:10', 'max:2048'],
|
||||
'devices' => ['nullable', 'array'],
|
||||
'devices.*.type' => ['required_with:devices', Rule::in(array_keys(\App\Models\VmDevice::typesFor($this->user())))],
|
||||
'devices.*.slot' => ['nullable', 'string', 'max:32'],
|
||||
'devices.*.config' => ['nullable', 'array'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user