Error when trying to add a query that has a join and one or more wheres and any of these not specified for which table
Closed this issue · 0 comments
mainginski commented
Ex:
Trying in controller:
$products = Products::join('prices', 'products.id', '=', 'prices.products_id')->select('products.*', 'prices.value')->where("name", "LIKE", "%test%")->orderBy('name','ASC')->get()
We will get the following query:
select [products].*, [prices].[value] from [products] inner join [prices] on [products].[id] = [prices].[products_id] where [name] LIKE %test% order by [name] asc
And the error:
`Undefined variable: table
So far, the 'right' is:
$products = Products::join('prices', 'products.id', '=', 'prices.products_id')->select('products.*', 'prices.value')->where("products.name", "LIKE", "%test%")->orderBy('name','ASC')->get()