Ejemplo n.º 1
0
 /**
  * Buiding collections to tree.
  *
  * @param  Collection $source
  * @return object
  */
 public function tree(Collection $source)
 {
     $source->load(implode('.', array_fill(0, 20, 'children')));
     $source->map(function ($item) {
         $item->children->sortBy('sort');
     });
     return $source;
 }
Ejemplo n.º 2
0
 /**
  * Find inner relations and load them on target model.
  *
  * @param Model|\Illuminate\Database\Eloquent\Collection $loadee
  *
  * @return void
  */
 protected function loadRelations($loadee)
 {
     $relations = $this->reference->relations();
     if ($relations) {
         $loadee->load($relations);
     }
 }