public function crudTree($model, $scope = CrudModel::DEFAULT_SCOPE) { $obj = CrudModel::createInstance($model, $scope); if ($this->request->ajax()) { $params = $this->request->all(); $params['search'] = !empty($params['search']['value']) ? $params['search']['value'] : ''; return CrudModelCollectionBuilder::createTree($obj, $params)->applyContextFilter()->fetch(); } return $this->view->make($obj->resolveView('tree'), ['crudObj' => $obj]); }
public function getOptions() { $class = CrudModel::resolveClass($this->config['model']); $modelObj = new $class(); if (!empty($this->config['find']) && !empty($this->config['model'])) { $method = $method = 'selectOptions' . studly_case($this->config['find']); $val = $this->getValue(); if (!is_array($val)) { if ($val instanceof Collection) { $val = $val->toArray(); } elseif (is_scalar($val)) { $val = [$val]; } } return $modelObj->{$method}($this->getName(), $val); } if (!empty($this->config['model'])) { return CrudModelCollectionBuilder::createTree($modelObj)->fetch(); } elseif (!empty($this->config['find']) && empty($this->config['model'])) { $method = $method = 'selectOptions' . studly_case($this->config['find']); return $this->model->{$method}($this->getName()); } }