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....

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

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的算法代码
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据