mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
feat(filament): default performance items to 1 (#1216)
This commit is contained in:
@@ -58,17 +58,19 @@ class PerformanceForm
|
||||
->live(true)
|
||||
->key('song.performances')
|
||||
->collapsible()
|
||||
->defaultItems(0)
|
||||
->defaultItems(1)
|
||||
->columns(3)
|
||||
->columnSpanFull()
|
||||
->reorderableWithButtons()
|
||||
->formatStateUsing(function ($livewire, Get $get): array {
|
||||
->formatStateUsing(function ($livewire, Get $get, array $state): array {
|
||||
/** @var Song|null $song */
|
||||
$song = $livewire instanceof PerformanceSongRelationManager
|
||||
? $livewire->getOwnerRecord()
|
||||
: Song::query()->find($get(Performance::ATTRIBUTE_SONG));
|
||||
|
||||
return PerformanceSongRelationManager::formatArtists($song);
|
||||
$artists = PerformanceSongRelationManager::formatArtists($song);
|
||||
|
||||
return blank($artists) ? $state : $artists;
|
||||
})
|
||||
->schema([
|
||||
BelongsTo::make(Artist::ATTRIBUTE_ID)
|
||||
@@ -110,7 +112,7 @@ class PerformanceForm
|
||||
->helperText(__('filament.fields.performance.member_alias.help')),
|
||||
]),
|
||||
])
|
||||
->saveRelationshipsUsing(fn (Get $get, ?array $state) => PerformanceSongRelationManager::saveArtists(intval($get(Performance::ATTRIBUTE_SONG)), $state)),
|
||||
->saveRelationshipsUsing(fn (Get $get, ?array $state) => PerformanceSongRelationManager::saveArtists($get(Performance::ATTRIBUTE_SONG), $state)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ class PerformanceSongRelationManager extends PerformanceRelationManager
|
||||
/**
|
||||
* Save the artists to the action.
|
||||
*/
|
||||
public static function saveArtists(Song|int|null $song = null, ?array $performances = []): void
|
||||
public static function saveArtists(Song|int|null $song = null, array $performances = []): void
|
||||
{
|
||||
if (is_null($song) || blank($performances)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user