/** * Handle the command. */ public function handle() { $model = $this->builder->getModel(); /* * If the builder has an entries handler * then call it through the container and * let it load the entries itself. */ if ($handler = $this->builder->getTreeOption('entries')) { app()->call($handler, ['builder' => $this->builder]); return; } $entries = $this->builder->getTreeEntries(); /* * If the entries have already been set on the * tree then return. Nothing to do here. * * If the model is not set then they need * to load the tree entries themselves. */ if (!$entries->isEmpty() || !$model) { return; } /* * Resolve the model out of the container. */ $repository = $this->builder->getTreeRepository(); /* * If the repository is an instance of * TreeRepositoryInterface use it. */ if ($repository instanceof TreeRepositoryInterface) { $this->builder->setTreeEntries($repository->get($this->builder)); } }
/** * Handle the command. */ public function handle() { $this->builder->fire('saving', ['builder' => $this->builder]); $repository = $this->builder->getTreeRepository(); $repository->save($this->builder); $this->builder->fire('saved', ['builder' => $this->builder]); }
/** * Handle the command. */ public function handle() { $tree = $this->builder->getTree(); $model = $tree->getModel(); /** * If a repository is set * then we don't have * anything to do. */ if ($this->builder->getTreeRepository()) { return; } $repository = $tree->getOption('repository'); /** * If there is no repository * then skip this step. */ if (!$repository) { return; } /** * Set the repository on the form! */ $tree->setRepository(app()->make($repository, compact('model', 'tree'))); }