Skip to content

Lists with _id as key #418

Closed
Closed
@akaroot

Description

@akaroot

Hi,
when I am trying use lists method with _id as key

 MyModel::where( 'network_id', 5 )->lists('name', '_id');

I got an error "Illegal offset type"

in Arr.php line 295
at HandleExceptions->handleError('2', 'Illegal offset type', '/var/www/dhcp-l5/vendor/laravel/framework/src/Illuminate/Support/Arr.php', '295', array('array' => array(array('_id' => object(MongoId), 'name' => 'Other Name'), array('_id' => object(MongoId), 'name' => 'Some Name')), 'value' => 'name', 'key' => '_id', 'results' => array(), 'item' => array('_id' => object(MongoId), 'name' => 'Other Name'), 'itemValue' => 'Other Name', 'itemKey' => object(MongoId))) in Arr.php line 295
at Arr::pluck(array(array('_id' => object(MongoId), 'name' => 'Other Name'), array('_id' => object(MongoId), 'name' => 'Some Name')), 'name', '_id') in helpers.php line 243
at array_pluck(array(array('_id' => object(MongoId), 'name' => 'Other Name'), array('_id' => object(MongoId), 'name' => 'Some Name')), 'name', '_id') in Collection.php line 372
at Collection->lists('name', '_id') in Builder.php line 1507
at Builder->lists('name', '_id') in Builder.php line 221
at Builder->lists('name', '_id') in NetworkClass.php line 45

I got the same error with Query Builder

DB::table('my_collection')->where('network_id', 5 )->lists( 'name', '_id');

Laravel: 5.0.1
Laravel-mongodb: dev-master

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions