Laravel notifications are not being saved when using custom channel










0














I have done this (https://laravel.com/docs/5.7/notifications#database-notifications), I ran the migration, I created a toArray() and a toDatabase() functions in the notification, and the notifications are correctly being sent, however, notifications are not being saved. My HablameChannel::send() method can send many messages because a certificate can have many phone numbers to notify, so I send the same notification to all of them.



This is my channel code:



<?php

namespace AppChannels;

use AppModelsMessage;
use IlluminateNotificationsNotification;

class HablameChannel

/**
* Send the given notification.
* Envía las mensajes de
*
* @param AppModelsOwner $notifiable
* @param IlluminateNotificationsNotification


This is my notification code:



<?php

namespace AppNotifications;

use AppChannelsHablameChannel;
use AppModelsCertificate;
use AppModelsMessage;
use IlluminateBusQueueable;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsNotification;
use IlluminateSupportCarbon;
use IlluminateSupportCollection;

class CertificateToExpire extends Notification

use Queueable;

/**
* Certificado por el cual se va a notificar que está a punto de caducar.
*
* @var AppModelsCertificate
*/
protected $certificate;

/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(Certificate $certificate)

$this->certificate = $certificate;


/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)

return [HablameChannel::class];


/**
* Get the array representation of the notification.
*
* @param AppModelsOwner $notifiable
* @return array
*/
public function toArray($notifiable)

return $this->toHablame($notifiable)->toArray();


/**
* Obtiene los mensajes a enviar por Háblame SMS.
*
* @param AppModelsOwner $notifiable
* @return IlluminateSupportCollection


This is the code where I call for the notification:



$certificate->owner->notify(new CertificateToExpire($certificate));









share|improve this question




























    0














    I have done this (https://laravel.com/docs/5.7/notifications#database-notifications), I ran the migration, I created a toArray() and a toDatabase() functions in the notification, and the notifications are correctly being sent, however, notifications are not being saved. My HablameChannel::send() method can send many messages because a certificate can have many phone numbers to notify, so I send the same notification to all of them.



    This is my channel code:



    <?php

    namespace AppChannels;

    use AppModelsMessage;
    use IlluminateNotificationsNotification;

    class HablameChannel

    /**
    * Send the given notification.
    * Envía las mensajes de
    *
    * @param AppModelsOwner $notifiable
    * @param IlluminateNotificationsNotification


    This is my notification code:



    <?php

    namespace AppNotifications;

    use AppChannelsHablameChannel;
    use AppModelsCertificate;
    use AppModelsMessage;
    use IlluminateBusQueueable;
    use IlluminateContractsQueueShouldQueue;
    use IlluminateNotificationsNotification;
    use IlluminateSupportCarbon;
    use IlluminateSupportCollection;

    class CertificateToExpire extends Notification

    use Queueable;

    /**
    * Certificado por el cual se va a notificar que está a punto de caducar.
    *
    * @var AppModelsCertificate
    */
    protected $certificate;

    /**
    * Create a new notification instance.
    *
    * @return void
    */
    public function __construct(Certificate $certificate)

    $this->certificate = $certificate;


    /**
    * Get the notification's delivery channels.
    *
    * @param mixed $notifiable
    * @return array
    */
    public function via($notifiable)

    return [HablameChannel::class];


    /**
    * Get the array representation of the notification.
    *
    * @param AppModelsOwner $notifiable
    * @return array
    */
    public function toArray($notifiable)

    return $this->toHablame($notifiable)->toArray();


    /**
    * Obtiene los mensajes a enviar por Háblame SMS.
    *
    * @param AppModelsOwner $notifiable
    * @return IlluminateSupportCollection


    This is the code where I call for the notification:



    $certificate->owner->notify(new CertificateToExpire($certificate));









    share|improve this question


























      0












      0








      0







      I have done this (https://laravel.com/docs/5.7/notifications#database-notifications), I ran the migration, I created a toArray() and a toDatabase() functions in the notification, and the notifications are correctly being sent, however, notifications are not being saved. My HablameChannel::send() method can send many messages because a certificate can have many phone numbers to notify, so I send the same notification to all of them.



      This is my channel code:



      <?php

      namespace AppChannels;

      use AppModelsMessage;
      use IlluminateNotificationsNotification;

      class HablameChannel

      /**
      * Send the given notification.
      * Envía las mensajes de
      *
      * @param AppModelsOwner $notifiable
      * @param IlluminateNotificationsNotification


      This is my notification code:



      <?php

      namespace AppNotifications;

      use AppChannelsHablameChannel;
      use AppModelsCertificate;
      use AppModelsMessage;
      use IlluminateBusQueueable;
      use IlluminateContractsQueueShouldQueue;
      use IlluminateNotificationsNotification;
      use IlluminateSupportCarbon;
      use IlluminateSupportCollection;

      class CertificateToExpire extends Notification

      use Queueable;

      /**
      * Certificado por el cual se va a notificar que está a punto de caducar.
      *
      * @var AppModelsCertificate
      */
      protected $certificate;

      /**
      * Create a new notification instance.
      *
      * @return void
      */
      public function __construct(Certificate $certificate)

      $this->certificate = $certificate;


      /**
      * Get the notification's delivery channels.
      *
      * @param mixed $notifiable
      * @return array
      */
      public function via($notifiable)

      return [HablameChannel::class];


      /**
      * Get the array representation of the notification.
      *
      * @param AppModelsOwner $notifiable
      * @return array
      */
      public function toArray($notifiable)

      return $this->toHablame($notifiable)->toArray();


      /**
      * Obtiene los mensajes a enviar por Háblame SMS.
      *
      * @param AppModelsOwner $notifiable
      * @return IlluminateSupportCollection


      This is the code where I call for the notification:



      $certificate->owner->notify(new CertificateToExpire($certificate));









      share|improve this question















      I have done this (https://laravel.com/docs/5.7/notifications#database-notifications), I ran the migration, I created a toArray() and a toDatabase() functions in the notification, and the notifications are correctly being sent, however, notifications are not being saved. My HablameChannel::send() method can send many messages because a certificate can have many phone numbers to notify, so I send the same notification to all of them.



      This is my channel code:



      <?php

      namespace AppChannels;

      use AppModelsMessage;
      use IlluminateNotificationsNotification;

      class HablameChannel

      /**
      * Send the given notification.
      * Envía las mensajes de
      *
      * @param AppModelsOwner $notifiable
      * @param IlluminateNotificationsNotification


      This is my notification code:



      <?php

      namespace AppNotifications;

      use AppChannelsHablameChannel;
      use AppModelsCertificate;
      use AppModelsMessage;
      use IlluminateBusQueueable;
      use IlluminateContractsQueueShouldQueue;
      use IlluminateNotificationsNotification;
      use IlluminateSupportCarbon;
      use IlluminateSupportCollection;

      class CertificateToExpire extends Notification

      use Queueable;

      /**
      * Certificado por el cual se va a notificar que está a punto de caducar.
      *
      * @var AppModelsCertificate
      */
      protected $certificate;

      /**
      * Create a new notification instance.
      *
      * @return void
      */
      public function __construct(Certificate $certificate)

      $this->certificate = $certificate;


      /**
      * Get the notification's delivery channels.
      *
      * @param mixed $notifiable
      * @return array
      */
      public function via($notifiable)

      return [HablameChannel::class];


      /**
      * Get the array representation of the notification.
      *
      * @param AppModelsOwner $notifiable
      * @return array
      */
      public function toArray($notifiable)

      return $this->toHablame($notifiable)->toArray();


      /**
      * Obtiene los mensajes a enviar por Háblame SMS.
      *
      * @param AppModelsOwner $notifiable
      * @return IlluminateSupportCollection


      This is the code where I call for the notification:



      $certificate->owner->notify(new CertificateToExpire($certificate));






      laravel laravel-5 laravel-5.7 laravel-notification






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 3:07







      andreshg112

















      asked Nov 13 '18 at 2:50









      andreshg112andreshg112

      147315




      147315






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Sorry, I just had to add the database driver to CertificateToExpire::via() method.



          public function via($notifiable)

          return [HablameChannel::class, 'database'];






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273076%2flaravel-notifications-are-not-being-saved-when-using-custom-channel%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Sorry, I just had to add the database driver to CertificateToExpire::via() method.



            public function via($notifiable)

            return [HablameChannel::class, 'database'];






            share|improve this answer

























              0














              Sorry, I just had to add the database driver to CertificateToExpire::via() method.



              public function via($notifiable)

              return [HablameChannel::class, 'database'];






              share|improve this answer























                0












                0








                0






                Sorry, I just had to add the database driver to CertificateToExpire::via() method.



                public function via($notifiable)

                return [HablameChannel::class, 'database'];






                share|improve this answer












                Sorry, I just had to add the database driver to CertificateToExpire::via() method.



                public function via($notifiable)

                return [HablameChannel::class, 'database'];







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 3:12









                andreshg112andreshg112

                147315




                147315



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273076%2flaravel-notifications-are-not-being-saved-when-using-custom-channel%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto