douren7179 2017-01-16 17:56
浏览 92
已采纳

方法[sendEmail]不存在

I am new to laravel 5.3 . I am using cartalyst sentinel for authentication

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();
}

authenticate method in registration controller -

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

when i tried to submit the button then i got this error -

BadMethodCallException in Controller.php line 82: Method [sendEmail] does not exist.

Please help me , Thanks

  • 写回答

1条回答 默认 最新

  • dongxing1412 2017-01-24 14:01
    关注


    $this->sendEmail($user,$activation->code); is trying to call on a method that is supposed to be existing somewhere, but it's not finding it.

    You can simply define the function somewhere with all the logics you want. e.g.

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

    Hope this will solve your problem....

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真