public function root()
    {
        $category = $this->createModel();

        $category = $category->whereExists(function($query)
        {
            $query->select(\DB::raw(1))
                  ->from('category_hierarchy')
                  ->whereRaw(DB::getTablePrefix().'categories.id = '.DB::getTablePrefix().'category_hierarchy.category_id')
                  ->where('category_hierarchy.category_parent_id', 0);
        });

        return $category;
    }
public function root()
    {
        $category = $this->createModel();

        $category = $category->whereExists(function($query)
        {
            $query->select(\DB::raw(1))
                  ->from('category_hierarchy')
                  ->whereRaw(DB::getTablePrefix().'categories.id = '.DB::getTablePrefix().'category_hierarchy.category_id')
                  ->where('category_hierarchy.category_parent_id', 0);
        });

        return $category;
    }
public function root ( ) { $ category = $ this -> createModel ( ) ; $ category = $ category -> whereExists ( function ( $ query ) { $ query -> select ( \ DB :: raw ( 1 ) ) -> from ( 'category_hierarchy' ) -> whereRaw ( DB :: getTablePrefix ( ) . 'categories.id = ' . DB :: getTablePrefix ( ) . 'category_hierarchy.category_id' ) -> where ( 'category_hierarchy.category_parent_id' , 0 ) ; } ) ; return $ category ; }
Get only root category.

@return Category
Get only root category .