LMongo\Eloquent\Collection::modelKeys PHP Method

modelKeys() public method

Get the array of primary keys
public modelKeys ( ) : array
return array
    public function modelKeys()
    {
        return array_map(function ($m) {
            return $m->getKey();
        }, $this->items);
    }

Usage Example

 public function testCollectionDictionaryReturnsModelKeys()
 {
     $one = m::mock('LMongo\\Eloquent\\Model');
     $one->shouldReceive('getKey')->andReturn(1);
     $two = m::mock('LMongo\\Eloquent\\Model');
     $two->shouldReceive('getKey')->andReturn(2);
     $three = m::mock('LMongo\\Eloquent\\Model');
     $three->shouldReceive('getKey')->andReturn(3);
     $c = new Collection(array($one, $two, $three));
     $this->assertEquals(array(1, 2, 3), $c->modelKeys());
 }