Tag Management
The Pro theme also comes with a tag management option. To access this example, click the “Laravel Examples/Tag Management” link in the left sidebar or add /tags to the URL. In this section you can add and edit tags, but you can only delete them if they are not attached to any items. You can add new ones by clicking the “Add tag” button (above the table on the right). You will then be directed to a form which allows you to add new tags. Although you can add in the form only the name and color of a tag, you can write your own migrations to extend this functionality.
public function delete($id)
{
$this->tag = Tag::find($id);
if (count($this->tag->items) < 1) {
$this->tag->delete();
$this->showFailNotification = false;
$this->showSuccessNotification = true;
} else {
$this->showSuccessNotification = false;
$this->showFailNotification = true;
}
}
The policy which authorizes the user to access tags management pages is implemented in App\Policies\TagPolicy.php
.