build the backend structure and the fe for the Game

This commit is contained in:
2026-08-15 22:37:53 +02:00
parent c5fd3f9d79
commit 4340ca9e12
37 changed files with 1611 additions and 56 deletions
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Http\Requests;
use App\Models\Player;
use App\Models\Room;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class JoinRoomRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
protected function prepareForValidation(): void
{
$this->merge([
'join_code' => strtoupper(trim((string) $this->input('join_code'))),
'player_name' => trim((string) $this->input('player_name')),
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$roomId = Room::query()
->where('join_code', $this->input('join_code'))
->value('id');
return [
'join_code' => ['bail', 'string', 'required', 'size:6', Rule::exists(Room::class, 'join_code')],
'player_name' => ['required', 'string', 'max:50', Rule::unique(Player::class, 'name')->where('room_id', $roomId)],
];
}
public function messages(): array
{
return [
'join_code.exists' => 'Dieser Raumcode existiert nicht.',
'join_code.size' => 'Der Raumcode muss aus sechs Zeichen bestehen.',
'player_name.unique' => 'Dieser Name wird in dem Raum bereits verwendet.',
];
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class StoreRoomRequest 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
{
return [
'title' => ['nullable', 'string', 'max:100'],
'player_name' => ['required', 'string', 'max:50'],
'deck_id' => ['required', 'integer'],
];
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests;
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');
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.',
];
}
}