方法[sendEmail]不存在

时间:2017-01-16 17:56:06

标签: php laravel sentinel

我是laravel 5.3的新手。我正在使用cartalyst哨兵进行身份验证

Web.php

Route::post('/register','RegistrationController@register');
Route::get('/activate/{email}/{activationCode}' , 'RegistrationController@activate');

RegistrationController.php

public function register(Request $request){
    $user = Sentinel::register($request->all());
    $activation = Activation::create($user);
    $role = Sentinel::findRoleBySlug('student');
    $role->users()->attach($user);
    $this->sendEmail($user,$activation->code);
    Alert::info('Mail has been sent to activate your account', 'Confirmation Email')->persistent("Close this");
    return redirect::back();
}

注册控制器中的身份验证方法 -

public function activate($email,$activationCode){

    $user = User::whereEmail($email)->first();

    $sentinelUser = Sentinel::findById($user->id);

    if(Activation::complete($sentinelUser, $activationCode)){

        return redirect('/');

    }
}

this is the image of complete code of registrationController

当我尝试提交按钮时,我收到了此错误 -

  

Controller.php第82行中的BadMethodCallException:方法[sendEmail]不存在。

请帮助我,谢谢

1 个答案:

答案 0 :(得分:1)


    $this->sendEmail($user,$activation->code);试图调用一个应该存在于某处的方法,但它找不到它。

您可以使用所需的所有逻辑简单地定义函数。例如

private function SendEmail($user, $activation->code) { // your logic goes here }

希望这能解决你的问题......