66use Statamic \CP \Column ;
77use Statamic \Facades \Collection as CollectionAPI ;
88use Statamic \Facades \Scope ;
9+ use Statamic \Facades \Site ;
910use Statamic \Facades \User ;
1011
12+ use function Statamic \trans as __ ;
13+
1114class Collection extends Widget
1215{
1316 public function component ()
@@ -28,7 +31,16 @@ public function component()
2831
2932 [$ sortColumn , $ sortDirection ] = $ this ->parseSort ($ collection );
3033
34+ $ blueprints = $ collection
35+ ->entryBlueprints ()
36+ ->reject ->hidden ()
37+ ->map (fn ($ blueprint ) => [
38+ 'handle ' => $ blueprint ->handle (),
39+ 'title ' => __ ($ blueprint ->title ()),
40+ ])->values ();
41+
3142 $ blueprint = $ collection ->entryBlueprint ();
43+
3244 $ columns = $ blueprint
3345 ->columns ()
3446 ->put ('status ' , Column::make ('status ' )
@@ -52,7 +64,10 @@ public function component()
5264 'initialPerPage ' => $ this ->config ('limit ' , 5 ),
5365 'canCreate ' => User::current ()->can ('create ' , [EntryContract::class, $ collection ]) && $ collection ->hasVisibleEntryBlueprint (),
5466 'createLabel ' => $ collection ->createLabel (),
55- 'blueprints ' => $ collection ->entryBlueprints ()->reject ->hidden ()->values (),
67+ 'blueprints ' => $ blueprints ->map (fn ($ blueprint ) => [
68+ ...$ blueprint ,
69+ 'createEntryUrl ' => cp_route ('collections.entries.create ' , [$ collection ->handle (), Site::selected (), 'blueprint ' => $ blueprint ['handle ' ]]),
70+ ])->all (),
5671 'listingUrl ' => cp_route ('collections.show ' , $ collection ),
5772 ]);
5873 }
0 commit comments