45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Club\Customers;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class UpdateCustomerRequest extends StoreCustomerRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Auth::guard('club')->check();
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*/
|
|
public function prepareForValidation(): void
|
|
{
|
|
parent::prepareForValidation();
|
|
$this->merge([
|
|
'question_id' => intval($this->input('question_id')),
|
|
'answers' => collect($this->input('answers'))->map(function (string $value) {
|
|
return intval($value);
|
|
})->toArray(),
|
|
'email' => auth()->user()->email,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return array_merge(parent::rules(), [
|
|
'password' => 'nullable',
|
|
'question_id' => 'required|integer',
|
|
'answers' => 'present|array',
|
|
'answers.*' => 'integer|min:0',
|
|
'email' => 'required|email:rfc,dns,spoof|max:255|exists:customers,email',
|
|
]);
|
|
}
|
|
}
|