Translate from SQL query to Eloquent


Hi, I'm new to eloquent and laravel, I have the following query, which runs perfectly from phpmyadmin:

SELECT * FROM vips_categories JOIN vips_products JOIN vip_archivos WHERE  vips_categories.parent_id = 1 AND vips_categories.parent_id = AND = vips_products.img

I wanted to do the following:

 $query = DB::table('vips_products AS Producto)
->join('vips_categories as Categoria.','Categoria.parent_id','=',$categoria)
->join('vips_categories as Categoria','Categoria.parent_id','=','')
->join('vip_archivos', '', '=', 'Producto.img')

But apparently it is incorrect, if someone could help me translate it I would be very grateful

asked by BorrachApps Mex 04.08.2017 в 20:49

1 answer


First of all, as I see, there is a syntax error in DB :: table ('vips_products AS Product), that string must be closed. Second, you are using Query Builder but not Eloquent. If what you need is to get that query in Query Builder it would be something like this:

$query = DB::table('vips_categories')
->join('vips_products','vips_categories.parent_id', '=', '')
->join('vip_archivos', '', '=', 'vips_products.img')
->where('vips_categories.parent_id', '1')
answered by 04.08.2017 / 21:42