@@ -96,10 +96,17 @@ public function form(Form $form): Form
9696 $ collection = Select::make ('collection_name ' )
9797 ->label (__ ('media::fields.collection ' ))
9898 ->options (function () {
99- return Media::query ()
99+ $ collections = Media::query ()
100100 ->distinct ()
101- ->pluck ('collection_name ' , ' collection_name ' )
101+ ->pluck ('collection_name ' )
102102 ->toArray ();
103+
104+ $ options = [];
105+ foreach ($ collections as $ name ) {
106+ $ options [$ name ] = $ name === 'default ' ? __ ('media::fields.default_collection ' ) : $ name ;
107+ }
108+
109+ return $ options ;
103110 })
104111 ->searchable ()
105112 ->required ()
@@ -335,13 +342,14 @@ public function toggleMediaSelection(int $mediaId)
335342 'description ' => $ media ->getAttribute ('description ' ) ?? '' ,
336343 'internal_note ' => $ media ->getAttribute ('internal_note ' ) ?? '' ,
337344 'alt ' => $ media ->getAttribute ('alt ' ) ?? '' ,
338- 'mime_type ' => $ media ->mime_type ?? '' ,
345+ 'mime_type ' => $ media ->getReadableMimeType () ,
339346 'write_protected ' => (bool ) $ media ->getOriginal ('write_protected ' ),
340347 'size ' => $ media ->size ,
341348 'dimensions ' => $ media ->getCustomProperty ('dimensions ' , []),
342349 'created_at ' => $ media ->created_at ,
343350 'updated_at ' => $ media ->updated_at ,
344351 'uploader_name ' => $ uploaderName ,
352+ 'collection_name ' => $ media ->collection_name ,
345353 ];
346354 } else {
347355 $ this ->selectedMediaMeta = [
@@ -359,6 +367,7 @@ public function toggleMediaSelection(int $mediaId)
359367 'created_at ' => null ,
360368 'updated_at ' => null ,
361369 'uploader_name ' => '- ' ,
370+ 'collection_name ' => '' ,
362371 ];
363372 }
364373 }
@@ -400,7 +409,7 @@ public function updatedSelectedMediaMeta($value, $field)
400409 if ($ this ->selectedMediaMeta ['id ' ]) {
401410 $ media = Media::where ('id ' , $ this ->selectedMediaMeta ['id ' ])->first ();
402411
403- if (in_array ($ field , ['title ' , 'description ' , 'internal_note ' , 'alt ' , 'name ' ])) {
412+ if (in_array ($ field , ['title ' , 'description ' , 'internal_note ' , 'alt ' , 'name ' , ' collection_name ' ])) {
404413 if ($ media ->getOriginal ('write_protected ' )) {
405414 return ;
406415 }
0 commit comments