我宁愿弄清楚为什么MSSQL以这种方式处理它,或者适配器,但由于直接在连接上的原始SELECT工作,你也可以用Eloquent来做:
App\User::fromQuery("select *, 'admin' as type from users");
您将从该结果中获得一系列模型。
使用查询构建器,您可以像这样尝试
$users = DB::table('users')->selectRaw("*, 'admin' AS type")->get();
如果你有User
模型那么
$users = User::selectRaw("*, 'admin' AS type")->get();
正如lagbox所建议的那样。此查询返回我需要的内容。谢谢你们。
DB::select("select *, 'admin' as type from users")