Example #1
0
 public function loadForeign(Models $models, $flags = null)
 {
     $keys = $models->pluckPropertyUnique($this->key);
     return $this->getForeignRepo()->findAll()->whereIn('id', $keys)->setFlags($flags)->loadRaw();
 }
Example #2
0
 /**
  * @covers ::pluckPropertyUnique
  */
 public function testPluckPropertyUnique()
 {
     $models = new Models([new Model(['id' => 10, 'name' => 'test1']), new Model(['id' => 20, 'name' => 'test2']), new Model(['id' => 10, 'name' => 'test2']), new Model(['id' => null, 'name' => 'test2'])]);
     $expected = [10, 20];
     $this->assertSame($expected, $models->pluckPropertyUnique('id'));
     $expected = ['test1', 'test2'];
     $this->assertSame($expected, $models->pluckPropertyUnique('name'));
 }