This commit is contained in:
2026-04-18 14:18:52 +02:00
parent 5b4d3d435e
commit f3e5100d5d
126 changed files with 743 additions and 795 deletions

View File

@@ -4,7 +4,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
class SiteBackground extends Model
{
@@ -16,19 +15,19 @@ class SiteBackground extends Model
protected $fillable = [
'date_start',
'date_end',
'default'
'default',
];
/**
* Returns the current IDs of active wallpaper
*/
public function getImages(): ? \Illuminate\Support\Collection
public function getImages(): ?\Illuminate\Support\Collection
{
$now = Carbon::now();
$byDates = $this->whereDate('date_start', '<=', $now)->whereDate('date_end', '>=', $now)->get()->pluck('id');
$default = $this->where('default', true)->get()->pluck('id');
return $byDates->isEmpty() ? $default : $byDates;
}
}