Example #1
0
 public function __call($name, $args)
 {
     if (!preg_match('/^add/', $name)) {
         throw new BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $name);
     }
     $className = preg_replace('/^add/', '', $name);
     return $this->addControl(Controls\Item::createControl($className, $args));
 }
Example #2
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     if ($name) {
         $this->name($name);
     }
     $this->bind = true;
 }
Example #3
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);
     });
 }