public function query($q = null)
    {
        return Product::where(function ($query) use ($q) {
                if ($q) {
                    foreach (explode(' ', $q) as $keyword) {
                        $query->where('description', 'like', "%{$keyword}%");
                    }
                }
            })
            ->orderBy('description')
            ->paginate();
    }
public function query($q = null)
    {
        return Product::where(function ($query) use ($q) {
                if ($q) {
                    foreach (explode(' ', $q) as $keyword) {
                        $query->where('description', 'like', "%{$keyword}%");
                    }
                }
            })
            ->orderBy('description')
            ->paginate();
    }
public function query ( $ q = null ) { return Product :: where ( function ( $ query ) use ( $ q ) { if ( $ q ) { foreach ( explode ( ' ' , $ q ) as $ keyword ) { $ query -> where ( 'description' , 'like' , "%{$keyword}%" ) ; } } } ) -> orderBy ( 'description' ) -> paginate ( ) ; }
Queries the product catalogue and returns a paginated result.

@param null|string $q
@return LengthAwarePaginator
Queries the product catalogue and returns a paginated result .