2016-05-13 20:20:21 +00:00
|
|
|
<?php namespace BookStack\Http\Controllers;
|
|
|
|
|
2018-09-25 11:30:50 +00:00
|
|
|
use BookStack\Actions\TagRepo;
|
2016-05-13 20:20:21 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class TagController extends Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
protected $tagRepo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TagController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(TagRepo $tagRepo)
|
|
|
|
{
|
|
|
|
$this->tagRepo = $tagRepo;
|
2016-12-04 16:51:39 +00:00
|
|
|
parent::__construct();
|
2016-05-13 20:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get tag name suggestions from a given search term.
|
|
|
|
*/
|
|
|
|
public function getNameSuggestions(Request $request)
|
|
|
|
{
|
2020-06-29 21:11:03 +00:00
|
|
|
$searchTerm = $request->get('search', null);
|
2016-05-13 20:20:21 +00:00
|
|
|
$suggestions = $this->tagRepo->getNameSuggestions($searchTerm);
|
|
|
|
return response()->json($suggestions);
|
|
|
|
}
|
|
|
|
|
2016-05-15 19:12:53 +00:00
|
|
|
/**
|
|
|
|
* Get tag value suggestions from a given search term.
|
|
|
|
*/
|
|
|
|
public function getValueSuggestions(Request $request)
|
|
|
|
{
|
2020-06-29 21:11:03 +00:00
|
|
|
$searchTerm = $request->get('search', null);
|
|
|
|
$tagName = $request->get('name', null);
|
2016-06-04 13:54:31 +00:00
|
|
|
$suggestions = $this->tagRepo->getValueSuggestions($searchTerm, $tagName);
|
2016-05-15 19:12:53 +00:00
|
|
|
return response()->json($suggestions);
|
|
|
|
}
|
2016-05-13 20:20:21 +00:00
|
|
|
}
|