mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 20:52:08 +00:00
build the backend structure and the fe for the Game
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ class Deck extends Model
|
||||
{
|
||||
return [
|
||||
'cards' => 'array',
|
||||
'is_system' => 'boolean'
|
||||
'is_system' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user