Files
WebAPP/app/Models/Player.php
Rhino 2e24a40d68 Stand: SMTP-Test, Admin-Mail-Tab, Notifiable-Fix, Lazy-Quill
- Fix: Notifiable-Trait zum User-Model hinzugefuegt (behebt notify()-500er)
- Installer: SMTP-Verbindungstest mit EsmtpTransport + Ueberspringen-Link
- Admin: Neuer E-Mail-Tab mit SMTP-Konfiguration + Verbindungstest
- Admin: Lazy Quill-Initialisierung (nur sichtbare Locale wird geladen)
- Uebersetzungen: 17 neue Mail-Keys in allen 6 Sprachen

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 07:30:37 +01:00

78 lines
1.8 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Player extends Model
{
use SoftDeletes;
protected $fillable = [
'team_id',
'first_name',
'last_name',
'birth_year',
'jersey_number',
'is_active',
'photo_permission',
'notes',
'profile_picture',
];
protected function casts(): array
{
return [
'is_active' => 'boolean',
'photo_permission' => 'boolean',
];
}
public function getFullNameAttribute(): string
{
return "{$this->first_name} {$this->last_name}";
}
public function team(): BelongsTo
{
return $this->belongsTo(Team::class);
}
public function parents(): BelongsToMany
{
return $this->belongsToMany(User::class, 'parent_player', 'player_id', 'parent_id')
->withPivot('relationship_label', 'created_at');
}
public function participations(): HasMany
{
return $this->hasMany(EventParticipant::class);
}
public function scopeActive($query)
{
return $query->where('is_active', true);
}
public function getAvatarUrl(): ?string
{
if ($this->profile_picture) {
return asset('storage/' . $this->profile_picture);
}
return null;
}
public function getInitials(): string
{
return mb_strtoupper(mb_substr($this->first_name, 0, 1) . mb_substr($this->last_name, 0, 1));
}
public function isRestorable(): bool
{
return $this->trashed() && $this->deleted_at->diffInDays(now()) < 7;
}
}