示例#1
0
 function mitterDeepArrayFilter($array)
 {
     $array = array_filter($array, 'mitterNullFilter');
     foreach ($array as $key => $item) {
         if (is_array($item)) {
             $array[$key] = mitterDeepArrayFilter($item);
         }
     }
     return $array;
 }
示例#2
0
 public function MorphToMany($name, $data = array())
 {
     $data = mitterDeepArrayFilter($data);
     $allRelations = $this->model->{$name};
     $inputedRelations = $this->newRelationsCollector($name, $data);
     $newRelations = $inputedRelations->diff($allRelations);
     $oldRelations = $allRelations->diff($inputedRelations);
     if (!$oldRelations->isEmpty()) {
         call_user_func(array($this->model, $name))->detach($oldRelations->lists('id')->toArray());
     }
     if (!$newRelations->isEmpty()) {
         call_user_func(array($this->model, $name))->attach($newRelations->lists('id')->toArray());
     }
 }