public function edit($modelName)
 {
     if (!($model = Config::getModelByClassName($modelName))) {
         throw new \Exception('Model does not exist');
     }
     return view('elegant::admin.modelsettings.edit', ['model' => $model]);
 }
 public function __construct($modelName)
 {
     $modelId = ElegantModel::generateId($modelName);
     if (!($model = Config::getModelById($modelId))) {
         throw new \Exception('Model not found with name ' . $modelName);
     }
     $this->elegantModel = $model;
     parent::__construct($this->elegantModel->getModelInstance());
 }
 /**
  * @param ReflectionClass $class
  * @return ElegantModelInterface|null
  */
 protected function getTranslatedModel(ReflectionClass $class)
 {
     $method = $class->getMethod('getTranslationModelName');
     $translationModelName = $method->invoke($class->newInstance());
     if ($model = Config::getModelByClassName($translationModelName)) {
         return $model;
     } else {
         return null;
     }
 }
 protected function registerEloquentEvents()
 {
     // Flush Elegant cache when anything changes for models registered by Elegant
     Event::listen('eloquent.*', function ($caller) {
         $callerClass = get_class($caller);
         if (!in_array($callerClass, ElegantConfig::getModelsAsClassNames())) {
             return;
         }
         if (in_array(Event::firing(), ['eloquent.saved', 'eloquent.deleted', 'eloquent.updated', 'eloquent.created']) && $this->cacheIsTaggable()) {
             Cache::tags('elegant-' . Support\ElegantModel::normalizeClassName($callerClass))->flush();
         }
     });
 }
 /**
  * @param Model $model
  * @return string
  */
 protected function getRelatedModelAsLink(Model $model)
 {
     $elegantModel = Config::getModelByClassName(get_class($model));
     $modelString = e($elegantModel->getModelAsString($model));
     return "<a href=\"{$elegantModel->getUrl($model)}\">{$modelString}</a>";
 }