]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/TagController.php
Finished moving tag-manager from a vue to a component
[bookstack] / app / Http / Controllers / TagController.php
1 <?php namespace BookStack\Http\Controllers;
2
3 use BookStack\Actions\TagRepo;
4 use Illuminate\Http\Request;
5
6 class TagController extends Controller
7 {
8
9     protected $tagRepo;
10
11     /**
12      * TagController constructor.
13      */
14     public function __construct(TagRepo $tagRepo)
15     {
16         $this->tagRepo = $tagRepo;
17         parent::__construct();
18     }
19
20     /**
21      * Get tag name suggestions from a given search term.
22      */
23     public function getNameSuggestions(Request $request)
24     {
25         $searchTerm = $request->get('search', null);
26         $suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
27         return response()->json($suggestions);
28     }
29
30     /**
31      * Get tag value suggestions from a given search term.
32      */
33     public function getValueSuggestions(Request $request)
34     {
35         $searchTerm = $request->get('search', null);
36         $tagName = $request->get('name', null);
37         $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
38         return response()->json($suggestions);
39     }
40 }