public function index()
{
$q = \Input::get('q');
$offset = $this->calcOffset(\Input::get('page'));
$results = $this->searchService->itemMatch($q, $this->perPage, $offset);
if (count($results) > 0) {
$res = $this->searchService->itemMatchCount($q);
$pagination = new Paginator($results, $res[0]->count, $this->perPage, null, array('path' => '/search'));
}
$users = $this->userService->getLikeUsername($q);
$users_array = $this->userService->getUsersToArray($users);
$templates = $this->templateService->getAll();
$tags = $this->searchTags($q);
return \View::make('search.index', compact('results', 'q', 'templates', 'pagination', 'tags', 'users', 'users_array'));
}