use Notifiable { notify as protected laravelNotify; }应该如何理解?

    use Notifiable {
        notify as protected laravelNotify;
    }

你好,请问这句语法应该如何理解。

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

Notifiable并不是类 这是trait的重写方式

示例

trait Calculator
{
    function increase($num){
        return $num+1;
    }
}

class ClassName
{
    use Calculator{
        increase as protected increaseMore;
    }

    function increase($num){
        $num=$num+10;
        return $this->increaseMore($num);
    }
}
6年前 评论
lafans 3年前
讨论数量: 4

Notifiable并不是类 这是trait的重写方式

示例

trait Calculator
{
    function increase($num){
        return $num+1;
    }
}

class ClassName
{
    use Calculator{
        increase as protected increaseMore;
    }

    function increase($num){
        $num=$num+10;
        return $this->increaseMore($num);
    }
}
6年前 评论
lafans 3年前
  • 这是在引入一个trait时,将其中的一个方法 notify 起了一个别名 laravelNotify,这是因为下面又重新声明了一个 notify 方法,如果不起别名,那么原来的 notify 方法就被当前类中的 notify overwriten 了。这样,就可以在当前类中的 notify 方法中写一些 关于 通知的逻辑代码,然后再调用原来的 notify 方法(现在的laravelNotify) 来真正的发送通知!
  • 参考
5年前 评论

Notifiable并不是类 这是trait的重写方式

示例

trait Calculator
{
    function increase($num){
        return $num+1;
    }
}

class ClassName
{
    use Calculator{
        increase as protected increaseMore;
    }

    function increase($num){
        $num=$num+10;
        return $this->increaseMore($num);
    }
}
6年前 评论
lafans 3年前
  • 这是在引入一个trait时,将其中的一个方法 notify 起了一个别名 laravelNotify,这是因为下面又重新声明了一个 notify 方法,如果不起别名,那么原来的 notify 方法就被当前类中的 notify overwriten 了。这样,就可以在当前类中的 notify 方法中写一些 关于 通知的逻辑代码,然后再调用原来的 notify 方法(现在的laravelNotify) 来真正的发送通知!
  • 参考
5年前 评论

@hustnzj 解答的很有实力啊

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!