public static function getEntityInstance($type) { $types = ['Page', 'Book', 'Chapter']; $className = str_replace([' ', '-', '_'], '', ucwords($type)); if (!in_array($className, $types)) { return null; } return app('BookStack\\' . $className); }