Example #1
0
 private function addReversedSingleRelation(Controls\Item $item, $field)
 {
     $values = collect($item->getUserValue());
     $relation = $this->getRelation($field);
     $ids = $values->pluck('id')->filter(null);
     $relation->whereNotIn('id', $ids->all())->delete();
     $values->each(function ($value) use(&$relation) {
         $relation->save($value);
     });
 }