public function __construct(EloquentModelsRepositoryInterface $models = null, ConfigInterface $config) { if (is_null($models)) { return redirect(route('dashboard.index')); } // Run parent __construct parent::__construct(); // Store repository for current model in controller $this->models = $models; // Store the name of the current model in view $this->elegant_model = $config->getModelByClassName($this->models->model()); View::share('elegant_model', $this->elegant_model); }
protected function addNewModels(array $newModels) { foreach (array_unique($newModels) as $model) { $this->info("Adding new model {$model}..."); $this->config->addModel(new $model()); $this->navigation->addItem(['class_name' => $model, 'slug' => ElegantModel::normalizeClassName($model)]); } }