public static function getModel($modelString) { $modelEloquent = new MagickEloquent(); $model = $modelEloquent->cleanModel($modelString); $modelPath = '\\App\\' . $model; if (!class_exists($modelPath)) { throw new \Exception("Class {$modelPath} not found"); } /* @var \Magia\Model\MagickEloquent $modelObject */ $modelObject = new $modelPath(); if (!is_a($modelObject, 'Magia\\Model\\MagickEloquent')) { throw new \Exception("Class {$model} is not a MagickEloquent Model"); } $modelObject->setUrlName($modelString); return $modelObject; }