Example #1
0
 /**
  * Use current dataprovider to perform seacrh
  * by given query and return view with results.
  * 
  * @return View
  */
 public function byQuery()
 {
     $input = (string) Input::get('q');
     if (!$input || Str::length($input) <= 1) {
         return View::make('search.results')->withTerm('');
     }
     if (is_a($this->search, 'Lib\\Services\\Search\\DbSearch')) {
         $encoded = $input;
     } else {
         $encoded = urlencode($input);
     }
     $clean = e($input);
     //make search cache section name
     $section = 'search' . $this->provider;
     if ($encoded) {
         if (Helpers::hasSuperAccess()) {
             $results = $this->search->byQuery($encoded);
         } else {
             if ($this->options->useCache()) {
                 $results = $this->cache->get($section, md5($encoded));
                 if (!$results || count($results) == 0) {
                     $results = $this->search->byQuery($encoded);
                     $this->cache->put($section, md5($encoded), $results);
                 }
             } else {
                 $results = $this->search->byQuery($encoded);
             }
         }
         return View::make('search.results')->withData($results)->withTerm($clean);
     }
     return View::make('search.results')->withTerm($clean);
 }
Example #2
0
 /**
  * Use current dataprovider to perform seacrh
  * by given query and return view with results.
  * 
  * @return View
  */
 public function byQuery()
 {
     $query = (string) Input::get('q');
     if (!$query || Str::length($query) <= 1) {
         return View::make('Search.Results')->withTerm('');
     }
     //don't encode the query if we will search our db as that will
     //cause problems
     if (is_a($this->search, 'Lib\\Services\\Search\\DbSearch')) {
         $encoded = $query;
     } else {
         $encoded = urlencode($query);
     }
     if (!Cache::tags('search')->has($this->provider . 'search' . $encoded)) {
         $results = $this->search->byQuery($encoded);
         Cache::tags('search')->put($this->provider . 'search' . $encoded, $results, 8640);
     } else {
         $results = Cache::tags('search')->get($this->provider . 'search' . $encoded);
     }
     return View::make('Search.Results')->withData($results)->withTerm(e($query));
 }