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
+1 -1
View File
@@ -16,7 +16,7 @@ class Deck extends Model
{
return [
'cards' => 'array',
'is_system' => 'boolean'
'is_system' => 'boolean',
];
}
+3 -3
View File
@@ -5,12 +5,12 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use phpDocumentor\Reflection\Types\Boolean;
class Player extends Model
{
protected $fillable = [
'room_id',
'room_id',
'user_id',
'name',
'is_moderator',
'last_seen_at',
@@ -58,7 +58,7 @@ class Player extends Model
return $this->is_moderator;
}
public function markAsSeen(): void
public function markAsSeen(): void
{
$this->update([
'last_seen_at' => now(),
+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);
}
+6 -5
View File
@@ -11,22 +11,23 @@ class Vote extends Model
'round',
'value',
'room_id',
'player_id'
'player_id',
];
protected function casts(): array
{
return [
'round' => 'integer',
'round' => 'integer',
];
}
public function room(): BelongsTo {
public function room(): BelongsTo
{
return $this->belongsTo(Room::class);
}
public function player(): BelongsTo {
public function player(): BelongsTo
{
return $this->belongsTo(Player::class);
}
}