app/Http/Controllers/Client/ClientScriptController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $user = User::where('id', Auth::user()->id)->first();
        $block_category = Script::where('users_id', Auth::user()->id)->get()->toArray();
        $cat = array();
        foreach ( $block_category as $row) {
            $cat[$row['parent_id']][$row['id']] = $row;
        }
        $block_category_tree =  $this->build_tree($cat, 0); 
        return view('client.script',['user' => $user,'block_tree' => $block_category_tree]);
    }
public function index ( ) { $ user = User :: where ( 'id' , Auth :: user ( ) -> id ) -> first ( ) ; $ block_category = Script :: where ( 'users_id' , Auth :: user ( ) -> id ) -> get ( ) -> toArray ( ) ; $ cat = array ( ) ; foreach ( $ block_category as $ row ) { $ cat [ $ row [ 'parent_id' ] ] [ $ row [ 'id' ] ] = $ row ; } $ block_category_tree = $ this -> build_tree ( $ cat , 0 ) ; return view ( 'client.script' , [ 'user' => $ user , 'block_tree' => $ block_category_tree ] ) ; }
Display a listing of the resource.
Display a listing of the resource .
//builde category tree //В цикле формируем массив разделов, ключом будет id родительской категории, а также массив разделов, ключом будет id категории //$data['parent_categories'] all goods category // $cat_ID[$row['id']][] = $row; need if need function 'find_parent' //SEND category tree to view