2015-04-02 60 views
0

通過重定向在laravel 5傳遞數據時,我有一些問題,我得到一些樣本代碼..在這裏我的代碼傳遞數據5

控制器

if($validator->fails()){ 
     return redirect()->back()->withErrors($validator->errors())->withInput(); 
    }else{ 
     if (Hash::check($request->old_password, $employee->password)){ 
      $user = [     
       'username' => $input['username'], 
       'password' => Hash::make($input['password']), 
      ]; 
      $employee->fill($user)->save(); 
      return redirect('/employees'); 
     }else{ 
      dd('test'); 
      $error = 'Your old password is incorrect'; 
      return redirect()->back()->with('error',$error); 
     } 

    } 

視圖

<div class="form-group"> 
        <label for="old_password" class="col-sm-2 control-label">Password Lama</label> 
        <div class="col-sm-5"> 
         <input type="password" class="form-control" name="old_password" placeholder="Password Lama" required />{{ $errors->first('old_password') }}{{ $error = session('error') }} 
        </div> 
       </div> 

有沒有錯誤信息,但$錯誤不能顯示我的消息..任何人都可以幫助我?

非常感謝......

+0

是否在您的刀片中有'print_r''$ error'? – 2015-04-02 16:15:51

+0

不,我不使用print_r,是這個問題嗎? – 2015-04-03 02:20:20

回答

0
}else{ 
      dd('test'); 
      $error = 'Your old password is incorrect'; 
      return redirect()->back()->with('error',$error); 
     } 

dd('test'),你退出應用程序的值存儲在會議召開之前。刪除,讓重定向。

其次,在處理會話時,請勿使用dd()。它可能創建不良結果,因爲session是一個可終止的中間件。

+0

ahh,sory ..我忘記刪除,但知道我的代碼可以運行..謝謝 – 2015-04-03 02:23:45

0

DD命令將信息返回給瀏覽器,然後停止執行代碼。嘗試評論這一點。