app/Http/Controllers/admin/CatesController.php
/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
Show the form for creating a new resource.
@return \Illuminate\Http\Response
Show the form for creating a new resource . @return \ Illuminate \ Http \ Response
public function create()
    {
        $cates = Cates::select('id','pid','classname','path','status',DB::raw("concat(id,',',path) as paths"))->orderBy('paths','asc')->paginate();
            foreach($cates as $k=>$v){
            $i = substr_count($v->path,',');
            $v->classname = str_repeat('|----',$i).$v->classname;
        }
        return view('admin.cates.create',['title'=>'添加分类','cates'=>self::getcates()]);
    }
public function create ( ) { $ cates = Cates :: select ( 'id' , 'pid' , 'classname' , 'path' , 'status' , DB :: raw ( " concat(id,',',path) as paths " ) ) -> orderBy ( 'paths' , 'asc' ) -> paginate ( ) ; foreach ( $ cates as $ k => $ v ) { $ i = substr_count ( $ v -> path , ',' ) ; $ v -> classname = str_repeat ( '|----' , $ i ) . $ v -> classname ; } return view ( 'admin.cates.create' , [ 'title' => '添加分类','cates' = >self:: ge tcat es ()]); }
Show the form for creating a new resource.
Show the form for creating a new resource .
//统计逗号出现的次数 //拼接|-- // dump(self::getcates());