26 lines
574 B
PHP
26 lines
574 B
PHP
<?php
|
|
namespace App\Handlers\Search;
|
|
|
|
use App\Handlers\Contracts\SearchHandler;
|
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
|
|
|
abstract class Search implements SearchHandler
|
|
{
|
|
/**
|
|
* Tokenize string for usage in LIKE clausules
|
|
*
|
|
* @param $term
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function tokenize($term)
|
|
{
|
|
$term = trim($term);
|
|
|
|
if (empty($term)) {
|
|
throw new InvalidArgumentException(trans('search.emptyString'));
|
|
}
|
|
|
|
return '%' . str_replace(' ', '%', $term) . '%';
|
|
}
|
|
} |