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)
|
->live(true)
|
||||||
->key('song.performances')
|
->key('song.performances')
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->defaultItems(0)
|
->defaultItems(1)
|
||||||
->columns(3)
|
->columns(3)
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->reorderableWithButtons()
|
->reorderableWithButtons()
|
||||||
->formatStateUsing(function ($livewire, Get $get): array {
|
->formatStateUsing(function ($livewire, Get $get, array $state): array {
|
||||||
/** @var Song|null $song */
|
/** @var Song|null $song */
|
||||||
$song = $livewire instanceof PerformanceSongRelationManager
|
$song = $livewire instanceof PerformanceSongRelationManager
|
||||||
? $livewire->getOwnerRecord()
|
? $livewire->getOwnerRecord()
|
||||||
: Song::query()->find($get(Performance::ATTRIBUTE_SONG));
|
: Song::query()->find($get(Performance::ATTRIBUTE_SONG));
|
||||||
|
|
||||||
return PerformanceSongRelationManager::formatArtists($song);
|
$artists = PerformanceSongRelationManager::formatArtists($song);
|
||||||
|
|
||||||
|
return blank($artists) ? $state : $artists;
|
||||||
})
|
})
|
||||||
->schema([
|
->schema([
|
||||||
BelongsTo::make(Artist::ATTRIBUTE_ID)
|
BelongsTo::make(Artist::ATTRIBUTE_ID)
|
||||||
@@ -110,7 +112,7 @@ class PerformanceForm
|
|||||||
->helperText(__('filament.fields.performance.member_alias.help')),
|
->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.
|
* 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)) {
|
if (is_null($song) || blank($performances)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user