コード例 #1
0
 public function loadModels(Models $models, $flags = null)
 {
     $models = $models->filter(function ($model) {
         return $model->{$this->classKey};
     });
     $groups = Arr::groupBy($models->toArray(), function ($model) {
         return $model->{$this->classKey};
     });
     foreach ($groups as $modelClass => &$models) {
         $keys = Arr::pluckUniqueProperty($models, $this->key);
         if ($keys) {
             $models = $modelClass::whereIn($this->getForeignKey(), $keys)->setFlags($flags)->loadRaw();
         } else {
             $models = [];
         }
     }
     return Arr::flatten($groups);
 }
コード例 #2
0
ファイル: ArrTest.php プロジェクト: clippings/util
 /**
  * @covers ::flatten
  * @dataProvider dataFlatten
  */
 public function testFlatten($array, $expected)
 {
     $this->assertSame($expected, Arr::flatten($array));
 }