feat: Store cooperation banners in a dedicated 'banner' media collection and update display logic to support both new and old storage.

This commit is contained in:
Yoga Pangestu 2026-02-02 13:45:50 +07:00
parent a6ab65adc4
commit b1bcb5dd14
2 changed files with 4 additions and 4 deletions

View File

@ -139,11 +139,11 @@ public static function infolist(Schema $schema): Schema
ImageEntry::make('banner')
->label('Banner')
->getStateUsing(fn (Cooperation $record): ?string => optional($record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->sortByDesc('created_at')->first())->getPathRelativeToRoot())
->getStateUsing(fn (Cooperation $record): ?string => optional($record->getMedia('banner')->sortByDesc('created_at')->first() ?? $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->sortByDesc('created_at')->first())->getPathRelativeToRoot())
->disk(config('filesystems.default'))
->visible(fn (Cooperation $record): bool => $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty()),
->visible(fn (Cooperation $record): bool => $record->getMedia('banner')->isNotEmpty() || $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty()),
])
->visible(fn (Cooperation $record): bool => $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty() && $record->getMedia('cooperations')->where('custom_properties.doc_type', 'proposal-template')->isNotEmpty()),
->visible(fn (Cooperation $record): bool => $record->getMedia('banner')->isNotEmpty() || $record->getMedia('cooperations')->where('custom_properties.doc_type', 'banner')->isNotEmpty() || $record->getMedia('cooperations')->where('custom_properties.doc_type', 'proposal-template')->isNotEmpty()),
TextEntry::make('description')
->label('Deskripsi'),

View File

@ -90,7 +90,7 @@ public static function configure(Schema $schema): Schema
->disk(config('filesystems.default'))
->acceptedFileTypes(['image/*'])
->maxSize(1024 * 3)
->collection('cooperations')
->collection('banner')
->customProperties(fn (): array => [
'feature' => 'cooperations',
'doc_type' => 'banner',