public function href($routeName = '', $customAttributes = [])
    {
        if(!$routeName) {
            $routeName = 'category.posts';
        }
        $getRoute = Route::getRoutes()->getByName($routeName);
        if($getRoute) {
            $routeParams = Route::getRoutes()->getByName($routeName)->parameterNames();

            // translating language
            if($this->getTranslateLanguage()) {
                $languageSlug = $this->getTranslateLanguage();
            }
            else{
                $languageSlug = App::getLocale();
            }

            //set only requested params
            $params = [];
            foreach($routeParams as $name){

                switch ($name){
                case 'postTypeSlug';

                    $postType = PostType::findByID($this->postTypeID);
                    $params['postTypeSlug'] = cleanPostTypeSlug($postType->slug);
                    break;

                case 'categorySlug';
                    $params['categorySlug'] = $this->slug;
                    break;

                case 'categoryID';
                    $params['categoryID'] = $this->categoryID;
                    break;

                case 'lang';
                    // don't show language slug on default language
                    if(config('project.hideDefaultLanguageInURL') && $languageSlug !=  Language::getDefault('slug')) {
                        $params['lang'] = $languageSlug;
                    }
                    break;
                }
            }

            return  route($routeName, $params);
        }else{
            throw new \Exception("Route $routeName not found");
        }
    }
public function href($routeName = '', $customAttributes = [])
    {
        if(!$routeName) {
            $routeName = 'category.posts';
        }
        $getRoute = Route::getRoutes()->getByName($routeName);
        if($getRoute) {
            $routeParams = Route::getRoutes()->getByName($routeName)->parameterNames();

            // translating language
            if($this->getTranslateLanguage()) {
                $languageSlug = $this->getTranslateLanguage();
            }
            else{
                $languageSlug = App::getLocale();
            }

            //set only requested params
            $params = [];
            foreach($routeParams as $name){

                switch ($name){
                case 'postTypeSlug';

                    $postType = PostType::findByID($this->postTypeID);
                    $params['postTypeSlug'] = cleanPostTypeSlug($postType->slug);
                    break;

                case 'categorySlug';
                    $params['categorySlug'] = $this->slug;
                    break;

                case 'categoryID';
                    $params['categoryID'] = $this->categoryID;
                    break;

                case 'lang';
                    // don't show language slug on default language
                    if(config('project.hideDefaultLanguageInURL') && $languageSlug !=  Language::getDefault('slug')) {
                        $params['lang'] = $languageSlug;
                    }
                    break;
                }
            }

            return  route($routeName, $params);
        }else{
            throw new \Exception("Route $routeName not found");
        }
    }
public function href ( $ routeName = '' , $ customAttributes = [ ] ) { if ( ! $ routeName ) { $ routeName = 'category.posts' ; } $ getRoute = Route :: getRoutes ( ) -> getByName ( $ routeName ) ; if ( $ getRoute ) { $ routeParams = Route :: getRoutes ( ) -> getByName ( $ routeName ) -> parameterNames ( ) ; // translating language if ( $ this -> getTranslateLanguage ( ) ) { $ languageSlug = $ this -> getTranslateLanguage ( ) ; } else { $ languageSlug = App :: getLocale ( ) ; } //set only requested params $ params = [ ] ; foreach ( $ routeParams as $ name ) { switch ( $ name ) { case 'postTypeSlug' ; $ postType = PostType :: findByID ( $ this -> postTypeID ) ; $ params [ 'postTypeSlug' ] = cleanPostTypeSlug ( $ postType -> slug ) ; break ; case 'categorySlug' ; $ params [ 'categorySlug' ] = $ this -> slug ; break ; case 'categoryID' ; $ params [ 'categoryID' ] = $ this -> categoryID ; break ; case 'lang' ; // don't show language slug on default language if ( config ( 'project.hideDefaultLanguageInURL' ) && $ languageSlug != Language :: getDefault ( 'slug' ) ) { $ params [ 'lang' ] = $ languageSlug ; } break ; } } return route ( $ routeName , $ params ) ; } else { throw new \ Exception ( "Route $routeName not found" ) ; } }
Generate a custom URL to a category.

@param  string $routeName
@param  array  $customAttributes
@return string
@throws \Exception
Generate a custom URL to a category .