mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 19:52:09 +00:00
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Models\Room;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class SubmitVoteRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$room = $this->route('room');
|
|
|
|
if (! $room instanceof Room) {
|
|
return ['value' => ['prohibited']];
|
|
}
|
|
|
|
return [
|
|
'value' => ['bail', 'required', 'string', Rule::in(array_column($room->deck_config['cards'], 'key'))],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'value.required' => 'Du musst eine Karte auswählen.',
|
|
'value.in' => 'Diese Karte gehört nicht zum verwendeten Deck.',
|
|
];
|
|
}
|
|
}
|