DB query builder toArray() laravel 4

前端 未结 7 1261
野性不改
野性不改 2021-02-01 13:32

I\'m trying to convert a query to an array with the method toArray() but it doesn\'t work for the query builder. Any ideas for convert it?

Example



        
7条回答
  •  无人及你
    2021-02-01 13:48

    toArray is a model method of Eloquent, so you need to a Eloquent model, try this:

     User::where('name', '=', 'Jhon')->get()->toArray();
    

    http://laravel.com/docs/eloquent#collections

提交回复
热议问题