mercredi 4 octobre 2017

Laravel : Invalid argument supplied for foreach() in Builder.php

I was trying to implement a filter search where $category_id & $industry_id will came from ajax request.

Here is the controller part:

  $products = DB::table('users')
      ->join('products','products.auth_id','users.id')
      ->Join('reviews','products.id','reviews.product_id')
      ->select('products.*','users.avatar',DB::raw('(sum(rating)/count(user_id)) as rating'))

     ->orwhereIn('products.category_id', $request->get('category_id'))   
     ->orwhereIn('products.industry_id',$request->get('industry_id'))   
     ->where('products.status','=','1')         
     ->groupBy('reviews.product_id')   
     ->latest()            
     ->get();

Problem is whether i send category_id or industry_id I got the following error in console :

(1/1) ErrorException
Invalid argument supplied for foreach()
in Builder.php (line 761)

What could be the possible error?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire