So i tried using multiple conditionals on my join but laravel assumes that on join i will be comparing mysql fields and not a constant value. Do I have to wrap this in a raw() method and then escape it using DB::connection()->getPdo()->quote() or are there any shortcuts to this?
->leftJoin('tags', function($join) use ($tags) {
$join->on('tags.id', '=', 'resource_tag.tag_id');
$join->on('tags.name', '=', $tags);
})
->leftJoin('tags', function($join) use ($tags) {
$join->on('tags.id', '=', 'resource_tag.tag_id');
$join->on('tags.name', '=', DB::raw(DB::connection()->getPdo()->quote($tags)));
})
This seemed to work but seemed a bit much.
I had to do this as well a few months ago. I haven't followed up to see if there was a better workaround, but I'll keep my eyes on this thread :) You're not alone.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community