app/Providers/AppServiceProvider.php
/**
     * Bootstrap any application services.
     *
     * @return void
     */
Bootstrap any application services.
@return void
Bootstrap any application services . @return void
public function boot()
    {
        Schema::defaultStringLength(191);
        $all_cats=\App\Model\Admin\Category::where('parent_id',0)->where('status','=',1)->get();
        foreach ($all_cats as $key => $category) {
           $children_data = array();
           $children = \App\Model\Admin\Category::where('parent_id',$category['id'])->where('status','=',1)->get();
           foreach ($children as $child) {
                    $children_data[] =(object) array(
                        'id'  => $child->id,
						'name'  => $child->name,
                        'seo_url'  => $child->seo_url,
						'image'  => $child->image
                    );
                }
            $all_cat[] =(object) array(
                    'id'     => $category->id,
					'name'     => $category->name,
                    'seo_url'     => $category->seo_url,
					'image'  => $child->image,
					'children' => $children_data
                );    
        }
              View::share('all_cat',$all_cat);
    }
public function boot ( ) { Schema :: defaultStringLength ( 191 ) ; $ all_cats = \ App \ Model \ Admin \ Category :: where ( 'parent_id' , 0 ) -> where ( 'status' , '=' , 1 ) -> get ( ) ; foreach ( $ all_cats as $ key => $ category ) { $ children_data = array ( ) ; $ children = \ App \ Model \ Admin \ Category :: where ( 'parent_id' , $ category [ 'id' ] ) -> where ( 'status' , '=' , 1 ) -> get ( ) ; foreach ( $ children as $ child ) { $ children_data [ ] = ( object ) array ( 'id' => $ child -> id , 'name' => $ child -> name , 'seo_url' => $ child -> seo_url , 'image' => $ child -> image ) ; } $ all_cat [ ] = ( object ) array ( 'id' => $ category -> id , 'name' => $ category -> name , 'seo_url' => $ category -> seo_url , 'image' => $ child -> image , 'children' => $ children_data ) ; } View :: share ( 'all_cat' , $ all_cat ) ; }
Bootstrap any application services.
Bootstrap any application services .