Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4: where is to_array()?

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'

like image 374
duality_ Avatar asked Dec 11 '22 18:12

duality_


1 Answers

Method in Laravel 4 are now camelCased

var_dump(Worker::find(1)->toArray());
like image 77
anthony.c Avatar answered Dec 22 '22 05:12

anthony.c