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)); }
public function __construct($name = null) { parent::__construct($name); if ($name) { $this->name($name); } $this->bind = true; }
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); }); }