如何在PHP中调用“父”特征方法?

这是我的代码

use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller {
    use ResetsPasswords;
    public function postReset(Request $request){
        // do some stuff
        // ...
        return parent::postReset($request); // <-here is the problem
    }

方法postReset存在于ResetsPasswords中,但是我编写的代码正在Controller类中寻找该方法.

有任何想法吗?

解决方法:

use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller {
    use ResetsPasswords {
      ResetsPassword::postReset as traitPostReset;
    };

    public function postReset(Request $request){
        // do some stuff
        // ...
        return $this->traitPostReset($request); 
    }
}
上一篇:c – 如何将traits功能委托给类成员?


下一篇:c – 为字符串输入特征