Support the ongoing development of Laravel.io →
Database
Last updated 2 years ago.
0

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.

0

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."
    )

Last updated 9 years ago.
0

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

0

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/

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.