finaur_poetra

whereHas to select in 3 table

Oct 3rd, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.33 KB | None | 0 0
  1. the controller
  2. $id = 7;
  3. $product = M_productImage::whereHas('product', function($q) use ($id)
  4.     {
  5.          $q->where('productCategory_id','!=', $id);
  6.            
  7.     })->orderBy('productImage_id','=', 'desc')->groupBy('product_id')->take(4)->get();
  8.  
  9.  
  10. to call in view
  11. main table
  12. $product->productImage_id;
  13. table
  14. $product->product->product_id;
Advertisement
Add Comment
Please, Sign In to add comment