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
+5 -8
View File
@@ -2,11 +2,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Override;
class Room extends Model
{
@@ -20,7 +18,7 @@ class Room extends Model
'state_version',
];
protected function casts() :array
protected function casts(): array
{
return [
'current_round' => 'integer',
@@ -37,15 +35,15 @@ class Room extends Model
});
}
private static function generateJoinCode(): string
private static function generateJoinCode(): string
{
$alphabet = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
do {
$code = '';
for($i = 0; $i < 6; $i++) {
$code .= $alphabet[random_int(0,strlen($alphabet)-1)];
for ($i = 0; $i < 6; $i++) {
$code .= $alphabet[random_int(0, strlen($alphabet) - 1)];
}
} while (static::where('join_code', $code)->exists());
@@ -53,14 +51,13 @@ class Room extends Model
}
public function players(): HasMany
{
return $this->hasMany(Player::class);
}
public function vote(): HasMany
public function votes(): HasMany
{
return $this->hasMany(Vote::class);
}