Convert laravel object to array

前端 未结 14 859
名媛妹妹
名媛妹妹 2020-12-13 19:33

Laravel output:

Array
(
    [0] = stdClass Object
    (
        [ID] = 5

    )

    [1] = stdClass Object
    (
        [ID] = 4

    )

)

14条回答
  •  北海茫月
    2020-12-13 20:16

    $res = ActivityServer::query()->select('channel_id')->where(['id' => $id])->first()->attributesToArray();
    

    I use get(), it returns an object, I use the attributesToArray() to change the object attribute to an array.

提交回复
热议问题