samedi 28 octobre 2017

Live Searching Option in LARAVEL php Homestead

In Laravel PHP, I wrote a code for "Live searching option". but it was returning the query from Database.I have provided the code below for Search Controller which I have handled separately.

public function search(Request $q)
{
    $prD= DB::table('products')->get();
    $arrPname = array();
    $arrPprice= array();
    $arrPdetail= array();
    $arrPimage= array();
    foreach ($prD as $prod) {
    $arrPname[]= $prod->pname;
    $arrPprice[]=$prod->price;
    $arrPdetail[]=$prod->details;
    $arrPdetail[]=$prod->details;
    $arrPimage[] = $prod->image;}

    $q = Input::get ( 'q' );
    $products = DB::table('products')-> where('pname','LIKE','%'.$q.'%')->get();
     if(count($product) > 0)
       return view ('search',compact("arrPname","arrPprice","arrPdetail","arrPimage"));
       /*return view (('search')->withDetails($product)->withQuery ( $q )*/
     else return view ('home')->withMessage('No Details found. Try to search again !');
    }

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zeGE4i
via IFTTT

Aucun commentaire:

Enregistrer un commentaire