登录laravel上返回类型错误

时间:2016-05-11 10:02:21

标签: php laravel

我收到错误:

authenticated()

这是我的自定义protected function authenticated(Request $request, $user){ $successmessage = 'Welcome back, '.Auth::user()->username.'!'; $request->session()->flash('success', $successmessage); return redirect()->intended($this->redirectPath()); }

    $mail->setTo($this->config->get('config_email'));
    $mail->setFrom($this->request->post['email']);
    $mail->setSender(html_entity_decode($this->request->post['name'],ENT_QUOTES,'UTF-8'));
    $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
    $mail->setText($this->request->post['enquiry']);
    $mail->send();

返回上面的错误。有什么帮助吗?

4 个答案:

答案 0 :(得分:0)

您需要来自\App\Http\Controllers\Auth\Request的用户请求 改变方法声明,如下所示:

protected function authenticated(\App\Http\Controllers\Auth\Request $request, $user){
                                ^^ //here is a change
    $successmessage = 'Welcome back, '.Auth::user()->username.'!';
    $request->session()->flash('success', $successmessage);
    return redirect()->intended($this->redirectPath());
}

答案 1 :(得分:0)

更改:

use App\Http\Requests;

use Request;

答案 2 :(得分:0)

检查App \ Http \ Controllers \ Auth文件夹中是否存在类Request。 如果存在,只需在命名空间后包含请求路径:

use App\Http\Controllers\Auth\Request;

答案 3 :(得分:0)

你可以这样做..

use Auth;
use Request;

protected function authenticated($user){ //Changed

    $successmessage = 'Welcome back, '.Auth::user()->username.'!';

    Request::session()->flash('success', $successmessage); //Changed

    return redirect()->intended($this->redirectPath());

}

我希望这会奏效。