Laravel 4: where is to_array()?

守給你的承諾、 提交于 2019-12-07 07:46:15

问题


Man, this is getting frustrating!

In Laravel 4, using Eloquent, this works: var_dump(Worker::find(1));. But if I try to use to_array(), it falls apart: var_dump(Worker::find(1)->to_array());. This throws the following exception:

call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Database\Query\Builder' does not have a method 'to_array'


回答1:


Method in Laravel 4 are now camelCased

var_dump(Worker::find(1)->toArray());


来源:https://stackoverflow.com/questions/14285182/laravel-4-where-is-to-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!