Laravel 4:to_array() 在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14285182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 4: where is to_array()?
提问by duality_
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:
在Laravel 4,用雄辩的,这个作品:var_dump(Worker::find(1));
。但是,如果我尝试使用to_array()
,它就会崩溃:var_dump(Worker::find(1)->to_array());
。这将引发以下异常:
call_user_func_array() expects parameter 1 to be a valid callback, class 'Illuminate\Database\Query\Builder' does not have a method 'to_array'
call_user_func_array() 期望参数 1 是一个有效的回调,类 'Illuminate\Database\Query\Builder' 没有方法 'to_array'
回答by anthony.c
Method in Laravel 4 are now camelCased
Laravel 4 中的方法现在是驼峰式的
var_dump(Worker::find(1)->toArray());