Reputation: 65
I have the following query join in MySQL.
left join the_fields as tf on
tf.tf_kode = x.tf_kode
and tf.is_payed is not null
I tried to convert to Laravel Query Builder:
->leftJoin('the_fields as tf', function ($j) {
$j->on('tf.tf_kode', '=', 'x.tf_kode');
$j->on('tf.is_payed','!=', null);
})
But it shows the error unknown column '' on clause
.
Upvotes: 3
Views: 809
Reputation: 4992
You can use any where
filter method or ->on
method:
->leftJoin('the_fields as tf', function ($j) {
$j->on('tf.tf_kode', '=', 'x.tf_kode')->whereNotNull('tf.is_payed');
// ->where(), ->whereBetween, ->whereIn() also works
});
Upvotes: 2