更新时间:2023-11-17 18:30:34
您需要使用原始表达式所以你可以使用这样的特殊功能。
You need to use raw expressions so you can use special functions like that.
Model::select(DB::raw('substr(id, 1, 4) as id'))->groupBy(DB::raw('substr(id, 1, 4)'))->get();
其中模型
是您想要的雄辩模型运行查询。
Where Model
is your Eloquent model you want to run the query on.