Banner zentral: je Website, Saison und Prioritaet, auch fuer Sonderangebote
Hinweise werden zu Bannern mit Website, Erscheinungsbildern, Prioritaet und optionalem Sonderangebot (Text, Termin und Link aus dem Angebot, sichtbar nur solange es beworben wird). Sonderangebote lassen sich mit einem Klick als Banner zeigen; die Liste nennt das heute sichtbare Banner. Banner-Texte der Erscheinungsbilder werden zu saisonalen Bannern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
791786ed3e
commit
d2b1a853dc
21 files changed
+618
-106
No files matched your search
@@ -9,6 +9,10 @@
|
||||
use App\Filament\Resources\Notices\Schemas\NoticeForm;
|
||||
use App\Filament\Resources\Notices\Tables\NoticesTable;
|
||||
use App\Models\Notice;
|
||||
use App\Models\Site;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\Banner;
|
||||
use App\Themes\ThemeFactory;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -26,9 +30,9 @@ class NoticeResource extends Resource
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
|
||||
|
||||
protected static ?string $modelLabel = 'Hinweis';
|
||||
protected static ?string $modelLabel = 'Banner';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Hinweis-Banner';
|
||||
protected static ?string $pluralModelLabel = 'Banner & Hinweise';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
@@ -49,6 +53,31 @@ public static function getRelations(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The banner each website shows today (none = null), with the website.
|
||||
*
|
||||
* @return list<array{site: Site, banner: Banner|null}>
|
||||
*/
|
||||
public static function bannersToday(): array
|
||||
{
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
// once() keys its cache by the variables the closure uses, so each landlord gets its own entry.
|
||||
return once(function () use ($tenantId): array {
|
||||
return Site::query()->when($tenantId, fn ($query) => $query->where('tenant_id', $tenantId))->orderBy('name')->get()
|
||||
->map(fn (Site $site): array => ['site' => $site, 'banner' => app(ThemeFactory::class)->forSite($site)->banner()])
|
||||
->all();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public static function noticeIdsShownToday(): array
|
||||
{
|
||||
return collect(self::bannersToday())->pluck('banner')->filter()->map(fn (Banner $banner): int => $banner->notice->id)->unique()->values()->all();
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in new issue
Block a user