public static function getSlug($removePrefix = false)
    {
        // get it from route
        $postTypeSlug = \Request::route('postTypeSlug');

        if(!$postTypeSlug) {

            // get it from url
            $url = explode('/', Request::route()->uri());

            if(isset($url[0]) && $url[0]) {
                $postType = PostType::findBySlug($url[0]);
                if($postType) {
                    $postTypeSlug = $postType->slug;
                }
            }
            if(!$postTypeSlug) {
                // get it from default post type
                $postTypeSlug = config('project.default_post_type');
            }
        }

        if($removePrefix) {
            return str_replace('post_', '', $postTypeSlug);
        }

        return $postTypeSlug;
    }
public static function getSlug($removePrefix = false)
    {
        // get it from route
        $postTypeSlug = \Request::route('postTypeSlug');

        if(!$postTypeSlug) {

            // get it from url
            $url = explode('/', Request::route()->uri());

            if(isset($url[0]) && $url[0]) {
                $postType = PostType::findBySlug($url[0]);
                if($postType) {
                    $postTypeSlug = $postType->slug;
                }
            }
            if(!$postTypeSlug) {
                // get it from default post type
                $postTypeSlug = config('project.default_post_type');
            }
        }

        if($removePrefix) {
            return str_replace('post_', '', $postTypeSlug);
        }

        return $postTypeSlug;
    }
public static function getSlug ( $ removePrefix = false ) { // get it from route $ postTypeSlug = \ Request :: route ( 'postTypeSlug' ) ; if ( ! $ postTypeSlug ) { // get it from url $ url = explode ( '/' , Request :: route ( ) -> uri ( ) ) ; if ( isset ( $ url [ 0 ] ) && $ url [ 0 ] ) { $ postType = PostType :: findBySlug ( $ url [ 0 ] ) ; if ( $ postType ) { $ postTypeSlug = $ postType -> slug ; } } if ( ! $ postTypeSlug ) { // get it from default post type $ postTypeSlug = config ( 'project.default_post_type' ) ; } } if ( $ removePrefix ) { return str_replace ( 'post_' , '' , $ postTypeSlug ) ; } return $ postTypeSlug ; }
Get current post type slug.

@param  bool $removePrefix It revmoes "post_" from slug
@return \Illuminate\Config\Repository|mixed
Get current post type slug .