Category Management
The Admin or Creator user has access to a categories management table page.
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 "Category Management" link in the left sidebar. You can add and edit categories here, but you can only delete them if they are not attached to any items.
public function destroy($id) {
if (!Category::find($id)->item->isEmpty()) {
return back()->withErrors('This category has items attached and can\'t be deleted.');
}
Category::find($id)->delete();
return redirect(route('category-management'))->with('status', 'Category successfully deleted.');
}
The policy which authorizes the user to access category management pages is implemented in App\Policies\CategoryPolicy.php
.