同时根据多个条件进行 join..on 的关联关系怎么写?
-
如果通过查询构造器可以这样写
$query = DB::table('test1') ->leftJoin('test2',function ($join) { $join->on('test1.apply_id', '=', 'test2.apply_id') ->on('test1.current_cycle', '=', 'test2.current_cycle'); })
-
现在我想在模型中定义关联关联 应该怎么写?(下面的写法是错的)
public function communication() { return $this->hasMany(CommunicationRemark::class, 'cycle', 'current_cycle') ->where('apply_id', '=', $this->apply_id); }
推荐文章: