简体   繁体   English

Laravel eloquent 生成器到原始

[英]Laravel eloquent builder to raw

Can any one convert the below given raw query to laravel eloquent query任何人都可以将下面给定的原始查询转换为 laravel eloquent 查询

SELECT `from`,`to`,`from`+`to` as total FROM `chats`;

i have tried select raw, and db raw but it is not working for the sum to from and to as total我已经尝试过 select raw 和 db raw 但它不适用于总和 to from 和 to as total

i find the way to do it我找到办法了

Chat::select('id','from', 'to', 'message','read','created_at',DB::raw(' from + to as total'))->get(); Chat::select('id','from', 'to', 'message','read','created_at',DB::raw(' from + to as total'))->get();

it's working fine thanx for your support guys.对于您的支持人员来说,它工作得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM