ldc-legaulois/app/Http/Requests/SurveyAnswersRequest.php
Jérémy Munsch c5e3a834fa phpcbf fix
2021-09-15 14:27:41 +02:00

36 lines
781 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class SurveyAnswersRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
// handle radio case
if (is_string($this->answers)) {
$this->merge(['answers' => [$this->answers]]);
}
return Auth::guard('customer')->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'answers' => 'required|array',
'answers.*' => 'exists:surveys_answers,id',
];
}
}