Example #1
0
 /**
  * @param  Models $models
  * @param  integer $flags
  * @return \Harp\Harp\Find
  */
 public function findModels(Models $models, $flags = null)
 {
     $keys = $models->pluckPropertyUnique($this->getKey());
     return $this->findAllWhereIn($this->getForeignKey(), $keys, $flags)->where($this->getForeignClassKey(), $this->getConfig()->getModelClass());
 }
Example #2
0
 /**
  * @covers ::pluckPropertyUnique
  */
 public function testPluckPropertyUnique()
 {
     $models = new Models([new City(['id' => 10, 'name' => 'test1']), new City(['id' => 20, 'name' => 'test2']), new City(['id' => 10, 'name' => 'test2']), new City(['id' => null, 'name' => 'test2'])]);
     $expected = [10, 20];
     $this->assertSame($expected, $models->pluckPropertyUnique('id'));
     $expected = ['test1', 'test2'];
     $this->assertSame($expected, $models->pluckPropertyUnique('name'));
 }