src/Repositories/TranslationRepository.php
public function search($locale, $partialCode, $perPage = 0)
    {
        // Get the namespace, if any:
        $colonIndex = stripos($partialCode, '::');
        $query      = $this->model->whereLocale($locale);
        if ($colonIndex === 0) {
            $query = $query->where('namespace', '!=', '*');
        } elseif ($colonIndex > 0) {
            $namespace   = substr($partialCode, 0, $colonIndex);
            $query       = $query->where('namespace', 'like', "%{$namespace}%");
            $partialCode = substr($partialCode, $colonIndex + 2);
        }

        // Divide the code in segments by .
        $elements = explode('.', $partialCode);
        foreach ($elements as $element) {
            if ($element) {
                $query = $query->where(function ($query) use ($element) {
                    $query->where('group', 'like', "%{$element}%")->orWhere('item', 'like', "%{$element}%")->orWhere('text', 'like', "%{$element}%");
                });
            }
        }

        return $perPage ? $query->paginate($perPage) : $query->get();
    }
public function search($locale, $partialCode, $perPage = 0)
    {
        // Get the namespace, if any:
        $colonIndex = stripos($partialCode, '::');
        $query      = $this->model->whereLocale($locale);
        if ($colonIndex === 0) {
            $query = $query->where('namespace', '!=', '*');
        } elseif ($colonIndex > 0) {
            $namespace   = substr($partialCode, 0, $colonIndex);
            $query       = $query->where('namespace', 'like', "%{$namespace}%");
            $partialCode = substr($partialCode, $colonIndex + 2);
        }

        // Divide the code in segments by .
        $elements = explode('.', $partialCode);
        foreach ($elements as $element) {
            if ($element) {
                $query = $query->where(function ($query) use ($element) {
                    $query->where('group', 'like', "%{$element}%")->orWhere('item', 'like', "%{$element}%")->orWhere('text', 'like', "%{$element}%");
                });
            }
        }

        return $perPage ? $query->paginate($perPage) : $query->get();
    }
public function search ( $ locale , $ partialCode , $ perPage = 0 ) { // Get the namespace, if any: $ colonIndex = stripos ( $ partialCode , '::' ) ; $ query = $ this -> model -> whereLocale ( $ locale ) ; if ( $ colonIndex === 0 ) { $ query = $ query -> where ( 'namespace' , '!=' , '*' ) ; } elseif ( $ colonIndex > 0 ) { $ namespace = substr ( $ partialCode , 0 , $ colonIndex ) ; $ query = $ query -> where ( 'namespace' , 'like' , "%{$namespace}%" ) ; $ partialCode = substr ( $ partialCode , $ colonIndex + 2 ) ; } // Divide the code in segments by . $ elements = explode ( '.' , $ partialCode ) ; foreach ( $ elements as $ element ) { if ( $ element ) { $ query = $ query -> where ( function ( $ query ) use ( $ element ) { $ query -> where ( 'group' , 'like' , "%{$element}%" ) -> orWhere ( 'item' , 'like' , "%{$element}%" ) -> orWhere ( 'text' , 'like' , "%{$element}%" ) ; } ) ; } } return $ perPage ? $ query -> paginate ( $ perPage ) : $ query -> get ( ) ; }
Search for entries given a partial code and a locale

@param  string  $locale
@param  string  $partialCode
@param  integer $perPage        0 if all, > 0 if paginated list with that number of elements per page.
@return Translation
Search for entries given a partial code and a locale