2017-10-24 9 views
0

私は自分のeコマースサイトの検索機能を構築していますが、結果には一部の製品のみが表示されます。たとえば、私は "Abrazadera"という名前の製品をすべて見つけることができますが、他の製品は見つかりません。助けてくれてありがとう。Laravel検索エンジンは一部の製品のみを表示します

ルート:

Route::get('search-product', [ 
'uses' => '[email protected]', 
'as' => 'search-product' 

コントローラー:

public function searchProduct(Request $request){ 

    // Sets the parameters from the get request to the variables. 
    $name = $request->input('name'); 
    $products = Product::where('name', 'LIKE', '%'.$name.'%')->paginate(15); 
    $marca = Category::all(); 
    $marcas = Marcas::all(); 
    $quicklinks = Quicklinks::all(); 
    return view('tienda.product')->with('products',$products)->with('marca',$marca)->with('marcas',$marcas)->with('quicklinks', $quicklinks); 
} 

HTML

@foreach ($products as $product) 
{{ $product->name }} 
@endforeach 
{{ $products->render()}} 
     @include('partials.brand') 
    @include('partials.footer') 
@stop 
+2

検索エンジンではなく検索機能を構築しています – unreleased

答えて

0

私は製品を検索するに従って示すともあなたはそれが次に表示されますページネーション15を入れていると思いますページ。そして、コンテンツ "%LIKE%"でチェックしなければならないかもしれません。

0
public function searchProduct(Request $request){ 

    // Sets the parameters from the get request to the variables. 
    $name = $request->input('name'); 
    $products = Product::where('name', 'LIKE', '%'.$name.'%'); 
    $marca = Category::all(); 
    $marcas = Marcas::all(); 
    $quicklinks = Quicklinks::all(); 
    return view('tienda.product')->with('products',$products)->with('marca',$marca)->with('marcas',$marcas)->with('quicklinks', $quicklinks); 
} 

ページネーションを削除して代わりに印刷しないのはなぜですか?

これは動作します。

関連する問題