3 namespace BookStack\Http\Controllers;
5 use BookStack\Actions\TagRepo;
6 use Illuminate\Http\Request;
8 class TagController extends Controller
10 protected TagRepo $tagRepo;
12 public function __construct(TagRepo $tagRepo)
14 $this->tagRepo = $tagRepo;
18 * Show a listing of existing tags in the system.
20 public function index(Request $request)
22 $search = $request->get('search', '');
23 $nameFilter = $request->get('name', '');
24 $tags = $this->tagRepo
25 ->queryWithTotals($search, $nameFilter)
27 ->appends(array_filter([
29 'name' => $nameFilter,
32 $this->setPageTitle(trans('entities.tags'));
34 return view('tags.index', [
37 'nameFilter' => $nameFilter,
42 * Get tag name suggestions from a given search term.
44 public function getNameSuggestions(Request $request)
46 $searchTerm = $request->get('search', '');
47 $suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
49 return response()->json($suggestions);
53 * Get tag value suggestions from a given search term.
55 public function getValueSuggestions(Request $request)
57 $searchTerm = $request->get('search', '');
58 $tagName = $request->get('name', '');
59 $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
61 return response()->json($suggestions);