MySQL如何在不同的数组中拆分列结果

MySQL如何在不同的数组中拆分列结果,mysql,laravel,eloquent,lumen,Mysql,Laravel,Eloquent,Lumen,我想把下降和上升列分开,作为一个单独的数组,我现在得到的结果是 { "title": "Location 1", "id": -1, "distance": "162 KM", "dropoff": "Location 2" }, 但我希望结果的格式如下 "pickup": [ {

我想把下降和上升列分开,作为一个单独的数组,我现在得到的结果是

{
    "title": "Location 1",
    "id": -1,
    "distance": "162 KM",
    "dropoff": "Location 2"
},
但我希望结果的格式如下

"pickup": [
    {
        "title": "Location 1",
        "id": 1,
        "distance": "155 KM"
    }
],
"dropoff": [
    {
        "title": "Location 2",
        "id": -1
    },
]
这是我的密码

$pick=DB::table('vehicleschedule')
->join(“作为pickuppoints的登机点”,\DB::raw(“在集合中查找(pickuppoints.id,vehicleschedule.pickuppoints)”),“>”,\DB::raw('0'))
->join(“作为下车的登机点”,\DB::raw(“在集合(dropoff.id,vehicleschedule.dropoff\u points)中查找下车点)”,“>”,\DB::raw('0'))
->挑选(
“pickuppoints.title”,
“pickuppoints.id”,
DB::原始(“concat(圆形((GLength(线串(pickuppoints.location,GeomFromText('POINT($lat$lng))))*111),'KM')作为距离”),
'dropoff.title作为dropoff'
)
->其中('vehicleschedule.routeID','=',$request->input('routeID'))
->其中('vehicleschedule.vehicleID','=',$request->input('vehicleID'))
->其中('vehicleschedule.timeSlot','=',$request->input('timeSlot'))
->其中(函数($query)使用($date,$day){
$query->where('vehicleschedule.dayofWeek','=',$day)
->或其中('vehicleschedule.date','=',$date);
})
->orderBy('pickuppoints.id')
->get();

我想你最好先问两个问题谢谢你,最后我也问了