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:
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