Tag Management


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

The store used for tag form can be found in app/Http/Controllers/TagController.

You can find the functions for tag form in resources/views/laravel-examples/tag folder.

Tag Controller

public function store(Request $request)
{
    $request->validate([

        'name' => 'required|min:3|max:255',
        'color' => 'required|min:3|max:255',
    ], [
        'name.required' => 'Name is required',
        'color.required' => 'color is required',
    ]);

    $tag = Tag::create([
        'name' => $request->name,
        'color' => $request->color,
    ]);

    return redirect(route('tag-management'))->with('success', 'New tag added successfully.');
}