Spielerpositionen, Statistiken, Fahrgemeinschaften, Spielfeld-Visualisierung
- PlayerPosition Enum (7 Handball-Positionen) mit Label/ShortLabel - Spielerstatistik pro Spiel (Tore, Würfe, TW-Paraden, Bemerkung) - Position-Dropdown in Spieler-Editor und Event-Stats-Formular - Statistik-Seite: TW zuerst, Trennlinie, Feldspieler, Position-Badges - Spielfeld-SVG mit Ampel-Performance (grün/gelb/rot) - Anklickbare Spieler im Spielfeld öffnen Detail-Modal - Fahrgemeinschaften (Anbieten, Zuordnen, Zurückziehen) - Übersetzungen in allen 6 Sprachen (de, en, pl, ru, ar, tr) - .gitignore für Laravel hinzugefügt - Demo-Daten mit Positionen und Statistiken Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
78
app/Models/EventPlayerStat.php
Normal file
78
app/Models/EventPlayerStat.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\PlayerPosition;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class EventPlayerStat extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'event_id',
|
||||
'player_id',
|
||||
'is_goalkeeper',
|
||||
'position',
|
||||
'goalkeeper_saves',
|
||||
'goalkeeper_shots',
|
||||
'goals',
|
||||
'shots',
|
||||
'note',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_goalkeeper' => 'boolean',
|
||||
'position' => PlayerPosition::class,
|
||||
'goalkeeper_saves' => 'integer',
|
||||
'goalkeeper_shots' => 'integer',
|
||||
'goals' => 'integer',
|
||||
'shots' => 'integer',
|
||||
];
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function player(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Player::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fangquote in Prozent (nur für Torwart).
|
||||
*/
|
||||
public function saveRate(): ?float
|
||||
{
|
||||
if (! $this->is_goalkeeper || ! $this->goalkeeper_shots || $this->goalkeeper_shots === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return round(($this->goalkeeper_saves / $this->goalkeeper_shots) * 100, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trefferquote in Prozent.
|
||||
*/
|
||||
public function hitRate(): ?float
|
||||
{
|
||||
if (! $this->shots || $this->shots === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return round(($this->goals / $this->shots) * 100, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob der Eintrag leer ist (keine relevanten Daten).
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return ! $this->is_goalkeeper
|
||||
&& ! $this->goalkeeper_saves
|
||||
&& ! $this->goalkeeper_shots
|
||||
&& ! $this->goals
|
||||
&& ! $this->shots
|
||||
&& ! $this->note;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user