app/Http/Controllers/Backend/BackendCategoryController.php
/**
     * Display a listing of all the categories.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of all the categories.
@return \Illuminate\Http\Response
Display a listing of all the categories . @return \ Illuminate \ Http \ Response
public function index($parent_id=0)
    {
        $categories = Category::childOf($parent_id)->withCount('children')->paginate(10);
        $next_parent_id = 0;
        $parent_name = null;
        if($parent_id>0){
            $current_parent_category = Category::findOrFail($parent_id);
            $next_parent_id = $current_parent_category->parent_id;
            $parent_name = $current_parent_category->name;
        }
       return view('backend.categories.index', compact('categories','next_parent_id','parent_name'));
    }
public function index ( $ parent_id = 0 ) { $ categories = Category :: childOf ( $ parent_id ) -> withCount ( 'children' ) -> paginate ( 10 ) ; $ next_parent_id = 0 ; $ parent_name = null ; if ( $ parent_id > 0 ) { $ current_parent_category = Category :: findOrFail ( $ parent_id ) ; $ next_parent_id = $ current_parent_category -> parent_id ; $ parent_name = $ current_parent_category -> name ; } return view ( 'backend.categories.index' , compact ( 'categories' , 'next_parent_id' , 'parent_name' ) ) ; }
Display a listing of all the categories.
Display a listing of all the categories .
// Get the categories child of the $id // Save the next Parent Category //Get the current name of the category parent