在选择laravel雄辩上添加任何默认字段

时间:2018-09-19 16:57:58

标签: laravel eloquent

如何在查询中添加默认字段为

SELECT "default_value" as _my_special_virtual_field FROM ...

此方法无法正常工作

->addSelect(['"default_value" as _my_special_virtual_field'])

1 个答案:

答案 0 :(得分:0)

您必须使用原始表达式:

->addSelect(DB::raw('"default_value" as _my_special_virtual_field'))
->selectRaw('"default_value" as _my_special_virtual_field')