app/Http/Controllers/admin/CatesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(CatesRequest $request,$id)
    {
        $cates = Cates::find($id);
        $pid = $request->input('pid','');
        if($pid == 0){
            $cates -> path = 0;
        }else{
            $p_data = Cates::find($pid);
            $cates -> path = $p_data->path.','.$p_data->id;
        }
        $cates-> pid = $pid;
        $cates-> classname = $request->input('classname');
        $res = $cates->save();
        if ($res) {
            return redirect('/admin/cates')-> with('success','修改成功');
        }else{
            return back()->with('error','修改失败');
        }
    }
public function update ( CatesRequest $ request , $ id ) { $ cates = Cates :: find ( $ id ) ; $ pid = $ request -> input ( 'pid' , '' ) ; if ( $ pid == 0 ) { $ cates -> path = 0 ; } else { $ p_data = Cates :: find ( $ pid ) ; $ cates -> path = $ p_data -> path . ',' . $ p_data -> id ; } $ cates -> pid = $ pid ; $ cates -> classname = $ request -> input ( 'classname' ) ; $ res = $ cates -> save ( ) ; if ( $ res ) { return redirect ( '/admin/cates' ) -> with ( 'success' , '修改成功'); } else { return back ( ) -> with ( 'error' , '修改失败'); } }
Update the specified resource in storage.
Update the specified resource in storage .
//将数据存入数据库中