它在laravel文档中说可以在连接上添加where子句,但每当我使用where子句尝试使用我的代码时,我都会收到错误:Call to undefined method Illuminate\Database\Query\JoinClause::where().任何人都知道如何在join子句中添加where子句?
Laravel网站示例:
DB::table('users')
->join('contacts', function($join)
{
$join->on('users.id', '=', 'contacts.user_id')
->where('contacts.user_id', '>', 5);
})
->get();
Run Code Online (Sandbox Code Playgroud)
代码我正在尝试实现:
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);
})
->get();
Run Code Online (Sandbox Code Playgroud)