File tree Expand file tree Collapse file tree
packages/media/src/Resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88use Filament \Resources \Resource ;
99use Filament \Forms \Components \View ;
1010use Illuminate \Support \Facades \Log ;
11+ use Filament \Forms \Components \Select ;
1112use Filament \Forms \Components \Section ;
1213use Filament \Forms \Components \Textarea ;
1314use Filament \Tables \Actions \EditAction ;
@@ -327,6 +328,22 @@ class=\"filament-button filament-button-size-sm inline-flex items-center justify
327328 ' );
328329 }),
329330
331+ Select::make ('collection_name ' )
332+ ->label (__ ('media::fields.collection ' ))
333+ ->disabled (fn ($ record ) => $ record ?->getOriginal('write_protected ' ))
334+ ->options (function () {
335+ return Media::query ()
336+ ->distinct ()
337+ ->pluck ('collection_name ' , 'collection_name ' )
338+ ->toArray ();
339+ })
340+ ->default (fn ($ record ) => $ record ->collection_name )
341+ ->afterStateUpdated (function ($ state , $ record ) {
342+ if ($ state !== $ record ->collection_name ) {
343+ $ record ->collection_name = $ state ;
344+ $ record ->save ();
345+ }
346+ }),
330347 ])
331348 ->columns (4 ),
332349
@@ -796,7 +813,7 @@ public static function table(Table $table): Table
796813
797814 return $ query ;
798815 }),
799- SelectFilter::make ('collection ' )
816+ SelectFilter::make ('collection_name ' )
800817 ->label (__ ('media::fields.collection ' ))
801818 ->options (function () {
802819 return Media::query ()
You can’t perform that action at this time.
0 commit comments