问题
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