diff --git a/resources/views/taxonomies/show.blade.php b/resources/views/taxonomies/show.blade.php index c2c3da0280..3aff3310d8 100644 --- a/resources/views/taxonomies/show.blade.php +++ b/resources/views/taxonomies/show.blade.php @@ -33,12 +33,12 @@ @endcan - @can('create', ['Statamic\Contracts\Taxonomies\Term', $taxonomy]) + @if($canCreate) - @endcan + @endif diff --git a/src/Http/Controllers/CP/Taxonomies/TaxonomiesController.php b/src/Http/Controllers/CP/Taxonomies/TaxonomiesController.php index 15b352d4a2..7c6c2550b5 100644 --- a/src/Http/Controllers/CP/Taxonomies/TaxonomiesController.php +++ b/src/Http/Controllers/CP/Taxonomies/TaxonomiesController.php @@ -4,6 +4,7 @@ use Illuminate\Http\Request; use Statamic\Contracts\Taxonomies\Taxonomy as TaxonomyContract; +use Statamic\Contracts\Taxonomies\Term as TermContract; use Statamic\Contracts\Taxonomies\TermRepository; use Statamic\CP\Column; use Statamic\Facades\Blueprint; @@ -80,6 +81,7 @@ public function show($taxonomy) 'taxonomy' => $taxonomy->handle(), 'blueprints' => $blueprints->pluck('handle')->all(), ]), + 'canCreate' => User::current()->can('create', [TermContract::class, $taxonomy]) && $taxonomy->hasVisibleTermBlueprint(), ]; if ($taxonomy->queryTerms()->count() === 0) { diff --git a/src/Taxonomies/Taxonomy.php b/src/Taxonomies/Taxonomy.php index f3fa2c6cb8..8c61204c02 100644 --- a/src/Taxonomies/Taxonomy.php +++ b/src/Taxonomies/Taxonomy.php @@ -166,6 +166,11 @@ public function fallbackTermBlueprint() return $blueprint; } + public function hasVisibleTermBlueprint() + { + return $this->termBlueprints()->reject->hidden()->isNotEmpty(); + } + public function sortField() { return 'title'; // todo