How does Laravel display this error or success message?
PHPz
PHPz 2017-05-16 16:50:29
0
1
378

The following is a controller for users to change passwords. I want to display the "success" or "failure" information of changing passwords in the view. How should I do this?

public function update(Requests\ResetPasswordRequest $request)
    {
        $id=\Auth::id();
        $user = User::findOrFail($id);
        $oldPassword=$request->input('oldPassword');

        if ($oldPassword==$user->password) {
            $user->update($request->input('password'));
            return redirect()->back(); //在视图中显示修改密码成功
        }else{
            return redirect()->back(); //在视图中显示修改密码失败
        }
    }
PHPz
PHPz

学习是最好的投资!

reply all(1)
某草草

Controller:

return redirect()->back()->with('message', '修改密码成功')

View:

{{ $message }}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template