Esempio n. 1
0
 /**
  * Ajax: to search for tag by keyword (used by auto complete tag field)
  *
  * @param Tag     $tag
  * @param string  $term
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getTags(Tag $tag, Request $request, $term = '')
 {
     $tags = [];
     $term = (string) $request->input('term', $term);
     if (!empty($term)) {
         $tags = $tag->searchTags($term)->filter(function (Tag $tag) {
             return !($tag->name == 'open' || $tag->name == 'closed');
         })->map(function (Tag $tag) {
             return ['value' => $tag->id, 'label' => $tag->fullname, 'bgcolor' => $tag->bgcolor];
         })->toArray();
     }
     return response()->json($tags);
 }