0
I need to replace the signal + for %20
Example : São+Paulo for Are%20Paulo
the search is on Laravel
with knockout
0
I need to replace the signal + for %20
Example : São+Paulo for Are%20Paulo
the search is on Laravel
with knockout
0
Dbsearch
public function byQuery($query)
{
return \Title::whereTitleLike(preg_replace("/[ -:\'\"]/i", '%', $query))->orderBy('created_at','desc')->get();
}
}
Blade
controller
original
{
$encoded = $query;
}
else
{
$encoded = urlencode($query);
}
modified
public function byQuery()
{
$query = (string) Input::get('genre');
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 = urldecode($query);
}
else
{
$encoded = urldecode($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));
}
Browser other questions tagged php laravel knockoutjs
You are not signed in. Login or sign up in order to post.
Utilize str_replace
– Valdeir Psr
Have you seen that?
– Denis Rudnei de Souza
used and didn’t work, see part of the code { $encoded = urldecode($query); }
– user100984
I could improve on the question with some extra explanation. Where does Knockout come into it?
– Sam
@Toninho if possible post the code you made and it didn’t work.
– Valdeir Psr
posted in a new answer
– user100984
If it’s just the +sign, I recommend using a str_replace, but if you want to replace characters and leave only the letters, then I advise you to use the preg_replace
– arllondias