app/Http/Controllers/admin/EntrepotController.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(Request $request, $id)
    { 
        $req = $request -> has('flag');
        $res = $request -> except(['_token']);
        if($req){
            if($res['num'] < '0'){
                return back()->with('error','库存数量不得少于0');
            }else{
                $entrepots = Entrepots::find($id);
                $entrepots -> num = $res['num'];
                $res = $entrepots -> save();
            }
        }else{
            if($res['num'] < '0'){
                return back()->with('error','库存数量不得少于0');
            }else{
                $entrepots = Entrepots::find($id);
                $entrepots -> num = $res['num'];
                $res = $entrepots -> save();
            }
        }
        if($res){
            return redirect('admin/entrepot')->with('success','修改成功');
        }else{
            return back()->with('error','修改失败');
        }
    }
public function update ( Request $ request , $ id ) { $ req = $ request -> has ( 'flag' ) ; $ res = $ request -> except ( [ '_token' ] ) ; if ( $ req ) { if ( $ res [ 'num' ] < '0' ) { return back ( ) -> with ( 'error' , '库存数量不得少于0'); } else { $ entrepots = Entrepots :: find ( $ id ) ; $ entrepots -> num = $ res [ 'num' ] ; $ res = $ entrepots -> save ( ) ; } } else { if ( $ res [ 'num' ] < '0' ) { return back ( ) -> with ( 'error' , '库存数量不得少于0'); } else { $ entrepots = Entrepots :: find ( $ id ) ; $ entrepots -> num = $ res [ 'num' ] ; $ res = $ entrepots -> save ( ) ; } } if ( $ res ) { return redirect ( 'admin/entrepot' ) -> with ( 'success' , '修改成功'); } else { return back ( ) -> with ( 'error' , '修改失败'); } }
Update the specified resource in storage.
Update the specified resource in storage .
//如果上传则执行第一个，不上传则执行第二个 //获取除了token以外所有上传的数据 //执行修改数据 //执行修改数据 // 如果添加成功则执行 // 添加不成功则执行 // dump($data);