【问题标题】:Where to find via() method and Notifiable model in Laravel 5.3?在 Laravel 5.3 中哪里可以找到 via() 方法和 Notifiable 模型?
【发布时间】:2017-04-11 15:05:39
【问题描述】:

我想在 Laravel 5.3 应用程序中使用 laravel-notification-channels/ionic-push-notifications 包。但我找不到package documentation 中提到的 via() 方法和 Notifiable 模型。我在哪里可以找到它们??

【问题讨论】:

    标签: laravel-5 push-notification laravel-notification


    【解决方案1】:

    我发现我应该先使用make:notification artisan 命令在app/Notifications 目录中创建一个通知类。然后,我会在这个类中找到 via() 方法。

    Notifiable 模型不是名称为“Notifiable”的模型,但任何模型都可以是 Notifiable 模型(我想向它的实例发送通知的模型),方法是使其使用 Notifiable trait:

    use Illuminate\Notifications\Notifiable;
    
    use App\Notifications\MyNotificationClass;
    
    class MyModel extends Model
    {
    
        use Notifiable;
    
        ....
    
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-03
      • 1970-01-01
      • 2011-06-16
      • 2015-04-28
      • 2017-05-13
      • 1970-01-01
      • 1970-01-01
      • 2020-12-15
      • 1970-01-01
      相关资源
      最近更新 更多