雄辩 - 用字符串值而不是列标题连接子句
我有一个关于Eloquent中的连接子句的问题,以及您是否可以在字符串值而不是表列上连接。
我有下面的代码,通过表“分类”查询一个嵌套集,该嵌套集在表“目标”中连接父/子记录。
关闭中的第二个语句是导致问题的声明;Eloquent假设这是一列,而我实际上只想加入 - 即,应该=一个字符串值,.$join
t1.parent_type = 'Destination'
t1.parent_type
Destination
$result = DB::connection()
->table('destinations AS d1')
->select(array('d1.title AS level1', 'd2.title AS level2'))
->leftJoin('taxonomy AS t1', function($join) {
$join->on('t1.parent_id', '=', 'd1.id');
$join->on('t1.parent_type', '=', 'Destination');
})
->leftJoin('destinations AS d2', 'd2.id', '=', 't1.child_id')
->where('d1.slug', '=', $slug)
->get();
有没有可能强迫Eloquent这样做?我尝试过替换为,但这也不起作用。'Destination'
DB::raw('Destination')
谢谢你。