]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/TagController.php
ce84bf4101e4c23f6437915a35c3d014a7c306a5
[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     }
18
19     /**
20      * Get tag name suggestions from a given search term.
21      */
22     public function getNameSuggestions(Request $request)
23     {
24         $searchTerm = $request->get('search', null);
25         $suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
26         return response()->json($suggestions);
27     }
28
29     /**
30      * Get tag value suggestions from a given search term.
31      */
32     public function getValueSuggestions(Request $request)
33     {
34         $searchTerm = $request->get('search', null);
35         $tagName = $request->get('name', null);
36         $suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
37         return response()->json($suggestions);
38     }
39 }