47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Servers;
|
||
|
|
|
||
|
|
use App\Enums\Environment;
|
||
|
|
use App\Enums\ServerType;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
use Illuminate\Support\Facades\Auth;
|
||
|
|
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
||
|
|
|
||
|
|
class StoreServerRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Determine if the user is authorized to make this request.
|
||
|
|
*
|
||
|
|
* @return boolean
|
||
|
|
*/
|
||
|
|
public function authorize()
|
||
|
|
{
|
||
|
|
return Auth::check();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'env' => [
|
||
|
|
'required', new EnumIsValidRule(Environment::class)
|
||
|
|
],
|
||
|
|
'virtual_ip' => 'required|ipV4',
|
||
|
|
'ssh' => 'required',
|
||
|
|
'infraweb_ip' => 'required|ipV4',
|
||
|
|
'title' => 'required|min:2|max:50',
|
||
|
|
'name' => 'required|min:2|max:50',
|
||
|
|
'function' => 'required|min:2|max:50',
|
||
|
|
'comment' => 'nullable|string',
|
||
|
|
'type' => [
|
||
|
|
'required', new EnumIsValidRule(ServerType::class)
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|