Finanzverwaltung und Saison-System
Neues Einnahmen-/Ausgaben-Modul mit Kategorie-Filter, Monats-Charts und Saison-basierter Filterung. Saison-Verwaltung im Admin-Bereich mit Möglichkeit zum Wechsel der aktuellen Saison. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
38
app/Models/Finance.php
Normal file
38
app/Models/Finance.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FinanceCategory;
|
||||
use App\Enums\FinanceType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Finance extends Model
|
||||
{
|
||||
protected $fillable = ['team_id', 'type', 'category', 'title', 'amount', 'date', 'notes'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'type' => FinanceType::class,
|
||||
'category' => FinanceCategory::class,
|
||||
'date' => 'date',
|
||||
'amount' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
public function team(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Team::class);
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function getFormattedAmountAttribute(): string
|
||||
{
|
||||
return number_format($this->amount / 100, 2, ',', '.') . ' €';
|
||||
}
|
||||
}
|
||||
34
app/Models/Season.php
Normal file
34
app/Models/Season.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Season extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'start_date', 'end_date', 'is_current'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'is_current' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function scopeCurrent($query)
|
||||
{
|
||||
return $query->where('is_current', true);
|
||||
}
|
||||
|
||||
public static function current(): ?self
|
||||
{
|
||||
return static::where('is_current', true)->first();
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return static::orderByDesc('start_date')->pluck('name', 'id')->toArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user