如何在查询中添加默认字段为
SELECT "default_value" as _my_special_virtual_field FROM ...
此方法无法正常工作
->addSelect(['"default_value" as _my_special_virtual_field'])
答案 0 :(得分:0)
您必须使用原始表达式:
->addSelect(DB::raw('"default_value" as _my_special_virtual_field'))
->selectRaw('"default_value" as _my_special_virtual_field')