2022-06-15 12:07:34 +02:00
|
|
|
<?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',
|
2022-06-15 14:09:52 +02:00
|
|
|
'datastore_pcc_id' => 'required|exists:datastore_pccs,id',
|
2022-06-15 12:07:34 +02:00
|
|
|
'comment' => 'nullable|string',
|
|
|
|
|
'type' => [
|
|
|
|
|
'required', new EnumIsValidRule(ServerType::class)
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|