diff --git a/src/Widgets/Collection.php b/src/Widgets/Collection.php index 46e187d174..3e09dd0270 100644 --- a/src/Widgets/Collection.php +++ b/src/Widgets/Collection.php @@ -6,8 +6,11 @@ use Statamic\CP\Column; use Statamic\Facades\Collection as CollectionAPI; use Statamic\Facades\Scope; +use Statamic\Facades\Site; use Statamic\Facades\User; +use function Statamic\trans as __; + class Collection extends Widget { public function component() @@ -28,7 +31,16 @@ public function component() [$sortColumn, $sortDirection] = $this->parseSort($collection); + $blueprints = $collection + ->entryBlueprints() + ->reject->hidden() + ->map(fn ($blueprint) => [ + 'handle' => $blueprint->handle(), + 'title' => __($blueprint->title()), + ])->values(); + $blueprint = $collection->entryBlueprint(); + $columns = $blueprint ->columns() ->put('status', Column::make('status') @@ -52,7 +64,10 @@ public function component() 'initialPerPage' => $this->config('limit', 5), 'canCreate' => User::current()->can('create', [EntryContract::class, $collection]) && $collection->hasVisibleEntryBlueprint(), 'createLabel' => $collection->createLabel(), - 'blueprints' => $collection->entryBlueprints()->reject->hidden()->values(), + 'blueprints' => $blueprints->map(fn ($blueprint) => [ + ...$blueprint, + 'createEntryUrl' => cp_route('collections.entries.create', [$collection->handle(), Site::selected(), 'blueprint' => $blueprint['handle']]), + ])->all(), 'listingUrl' => cp_route('collections.show', $collection), ]); }