Search similar tags by given string
public similar ( string $string, integer $take = 15, string | null $instanceId = null ) : Illuminate\Database\Eloquent\Collection | static[] | ||
$string | string | partial of word |
$take | integer | take count |
$instanceId | string | null | instance id of taggable |
return | Illuminate\Database\Eloquent\Collection | static[] |
/** * 해시태그 suggestion 리스트 * * @param Request $request * @param TagHandler $tag * @return mixed */ public function hashTag(Request $request, TagHandler $tag) { $tags = $tag->similar($request->get('string')); $suggestions = []; foreach ($tags as $tag) { $suggestions[] = ['id' => $tag->id, 'word' => $tag->word]; } return XePresenter::makeApi($suggestions); }