if you want add more condition on a
join
add more $join->on
or $join->orOn
.if you want to add a condition to your first select, add it outside join function.
DB::table('users')
->join('contacts', function($join)
{
$date = date('Y-m-d');
$join->on('users.id', '=', 'contacts.user_id');
})
->where('contacts.effective_date', '>=', $date);
->get();
DB::table('users')
->join('contacts', function($join)
{
$current_date = date('Y-m-d');
$join->on('users.id', '=', 'contacts.user_id')
->where('contacts.effective_date', '>', $current_date)
->where('contacts.effective_date', '=', $current_date);
})
->get();
$current_date = date('Y-m-d');
DB::table('users')
->join('contacts', function($join) use ($current_date)
{
$join->on('users.id', '=', 'contacts.user_id')
->where('contacts.effective_date', '>=', $current_date);
})
->get();
0 comments:
Post a Comment
Thanks