<?php

namespace App\Http\Controllers\Admin\Shop;

use App\Datatables\Admin\Shop\TagsDataTable;
use App\Http\Controllers\Controller;
use App\Repositories\Shop\TagGroups;
use App\Repositories\Shop\Tags;
use Illuminate\Http\Request;

class TagController extends Controller
{
    public function index(TagsDataTable $dataTable)
    {
        return $dataTable->render('Admin.Shop.Tags.list');
    }

    public function create()
    {
        $data = [];
        $data['tag_groups'] = TagGroups::getOptions();

        return view('Admin.Shop.Tags.create', $data);
    }

    public function store(Request $request)
    {
        $ret = Tags::store($request->all());

        return redirect()->route('Admin.Shop.Tags.index');
    }

    public function show($id)
    {
        $data = Tags::get($id);

        return view('Admin.Shop.Tags.view', $data);
    }

    public function edit($id)
    {
        $data = Tags::get($id);
        $data['tag_groups'] = TagGroups::getOptions();

        return view('Admin.Shop.Tags.edit', $data);
    }

    public function destroy($id)
    {
        return Tags::destroy($id);
    }
}
