2021-03-14 10:45:42 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
|
|
|
|
|
|
use ArondeParon\RequestSanitizer\Sanitizers\FilterVars;
|
|
|
|
|
use ArondeParon\RequestSanitizer\Traits\SanitizesInputs;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
|
*/
|
2021-03-14 10:45:42 +01:00
|
|
|
class ManageServiceRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
use SanitizesInputs;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* Using these sanitizers before proceeding the request
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
2021-03-14 10:45:42 +01:00
|
|
|
protected $sanitizers = [
|
|
|
|
|
'name' => [
|
|
|
|
|
FilterVars::class => [
|
|
|
|
|
'filter' => FILTER_SANITIZE_STRING
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
2021-12-19 15:57:24 +01:00
|
|
|
* @return boolean
|
2021-03-14 10:45:42 +01:00
|
|
|
*/
|
|
|
|
|
public function authorize()
|
|
|
|
|
{
|
|
|
|
|
return auth()->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
if ($this->isMethod('post')) {
|
|
|
|
|
return [
|
|
|
|
|
'name' => 'required|string|min:5|max:255',
|
|
|
|
|
'brand_id' => 'required|exists:brands,id'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
}
|