Category management

Out of the box you will have an example of category management (for the cases in which you are developing a blog or a shop). To access this example, click the "Examples/Category Management" link in the left sidebar or add /category to the URL. You can add and edit categories here, but you can only delete them if they are not attached to any items.

          
            @if ($category->items->isEmpty() && auth()->user()->can('delete', $category))
              <form action="{{ route('category.destroy', $category) }}" method="post">
                  @csrf
                  @method('delete')
                  <button type="button" class="dropdown-item" onclick="confirm('{{ __("Are you sure you want to delete this category?") }}') ? this.parentElement.submit() : ''">
                      {{ __('Delete') }}
                  </button>
              
            @endif
          
        

The policy which authorizes the user on categories management pages is implemented in App\Policies\CategoryPolicy.php.