]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/TagController.php
b0065af70f928e2f61cf8c8ec7d9050352503eb6
[bookstack] / app / Http / Controllers / TagController.php
1 <?php
2
3 namespace BookStack\Http\Controllers;
4
5 use BookStack\Actions\TagRepo;
6 use Illuminate\Http\Request;
7
8 class TagController extends Controller
9 {
10     protected $tagRepo;
11
12     /**
13      * TagController constructor.
14      */
15     public function __construct(TagRepo $tagRepo)
16     {
17         $this->tagRepo = $tagRepo;
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
28         return response()->json($suggestions);
29     }
30
31     /**
32      * Get tag value suggestions from a given search term.
33      */
34     public function getValueSuggestions(Request $request)
35     {
36         $searchTerm = $request->get('search', null);
37         $tagName = $request->get('name', null);
38         $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
39
40         return response()->json($suggestions);
41     }
42 }