ldc-legaulois/app/Http/Requests/SurveyAnswersRequest.php

37 lines
781 B
PHP
Raw Normal View History

2021-03-05 08:17:35 +01:00
<?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()
{
2021-04-30 21:30:05 +02:00
// handle radio case
if (is_string($this->answers)) {
$this->merge(['answers' => [$this->answers]]);
}
2021-03-05 08:17:35 +01:00
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',
];
}
}