Hmmm, I'm getting lost. Try using ``` to show a quote. I hate to admit it but I stay away from functions in my queries. I will do something like this:
$makes = DB::table('produced')
->select(
'produced.*',
'catalog.*',
'productions.*',
'customers.name as customer'
)
->leftJoin('catalog', 'produced.catalog_id', '=', 'catalog.id')
->leftJoin('productions', 'produced.production_id', '=', 'productions.id')
->leftJoin('customers', 'productions.customer_id', '=', 'customers.id')
// ->whereNotNull('pallet_id', 'AND')
->where('packed', '=', 0)
->where('flagged', '=', 0, 'AND')
->groupBy('production_id')
->get();
To debug your query I'd start from a simpler version and go from there.
illuminate3 said:
Hmmm, I'm getting lost. Try using ``` to show a quote. I hate to admit it but I stay away from functions in my queries.
Ok, just to be more clear this line is what I want to transform
ON (
((`Bookmarks`.`v_id` = `Vehicle`.`id`) OR ((`Bookmarks`.`v_id` IS NULL) AND (`Bookmarks`.`selling_user_id` = `Vehicle`.`user_id`)))
AND `Bookmarks`.`bookmark_user_id` = ".$this->userId."
)
Not really sure but hopefully this will get you forward a little bit ...
->whereNull('Bookmarks.v_id')
->orWhere('Bookmarks. v_id'', 'Vehicle.id')
->where('Bookmarks. selling_user_id', '=', 'Vehicle. user_id', 'AND')
->where('Bookmarks. bookmark_user_id', '=', $this->userId, 'AND')
I just read this and haven't tried it but it might help to with building the above. http://laravel.com/docs/5.1/queries#unions
Thank you, Eventually this what really helped me figure out how to include an or clause in join http://www.rickywiens.ca/blog/making-raw-join-queries-with-eloquent-and-laravel/
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community