Tuesday, April 11, 2017

How to solve Illegal offset type on the laravel eloquent?

I use this : https://github.com/jenssegers/laravel-mongodb

I use laravel 5.3

My laravel eloquent is like this :

$data = Employee::select('id', DB::raw('sum(salary+bonus) AS total'), 'name')->find($id);
dd($data);

So, I want sum 2 field in one record

When executed, there exist error like this :

1/1 ErrorException in Builder.php line 353: Illegal offset type

How can I solve it?



via samuel toh

Advertisement