Getting error routeNotificationFor() on laravel notifications











up vote
0
down vote

favorite














I'm trying to send email to members on my app and I get the following error:




production.ERROR: Call to undefined method
IlluminateDatabaseQueryBuilder::routeNotificationFor()
{"exception":"[object] (BadMethodCallException(code: 0): Call to
undefined method
IlluminateDatabaseQueryBuilder::routeNotificationFor() at
/var/www/vhosts/.../laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)




I have the members model with the Notifiable trait and the weird issue is that on my local machine the emails are delivered... The problem is on production...



Any ideas?



The notifications are fired with:



Notification::send($members_to_notify, new CommMessage($communication));


And the CommMessageclass is:



CommMessage.php



namespace AppNotificationsCommunications;

use IlluminateBusQueueable;
use IlluminateNotificationsNotification;
use IlluminateContractsQueueShouldQueue;
use IlluminateNotificationsMessagesMailMessage;
use AppMailCommunicationsMessage as Mailable;

class CommMessage extends Notification implements ShouldQueue
{

use Queueable;

private $communication;

/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($communication)
{
$this->communication = $communication;

}

/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Mailable
*/
public function toMail($notifiable)
{
return (new Mailable($this->communication))->to($notifiable->email);
}
}


The mailable Message class is:



Message.php



namespace AppMailCommunications;

use IlluminateBusQueueable;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
use IlluminateContractsQueueShouldQueue;

class Message extends Mailable
{
use Queueable, SerializesModels;

/**
* The appointment instance.
*
* @var Appointment
*/
public $communication;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct($communication)
{
$this->communication = $communication;

}

/**
* Build the message.
*
* @return $this
*/
public function build()
{
$this->replyTo($this->communication->school->email)
->markdown('emails.communications.message');

$this->subject($this->communication->title);

$this->withSwiftMessage(function ($message) {
$message->getHeaders()
->addTextHeader('X-Mailgun-Variables', json_encode([
'model_id' => $this->communication->id,
'model' => get_class($this->communication),
'email_type' => 11 //Communication message (EmailLogType)
]));
});

}

}









share|improve this question




























    up vote
    0
    down vote

    favorite














    I'm trying to send email to members on my app and I get the following error:




    production.ERROR: Call to undefined method
    IlluminateDatabaseQueryBuilder::routeNotificationFor()
    {"exception":"[object] (BadMethodCallException(code: 0): Call to
    undefined method
    IlluminateDatabaseQueryBuilder::routeNotificationFor() at
    /var/www/vhosts/.../laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)




    I have the members model with the Notifiable trait and the weird issue is that on my local machine the emails are delivered... The problem is on production...



    Any ideas?



    The notifications are fired with:



    Notification::send($members_to_notify, new CommMessage($communication));


    And the CommMessageclass is:



    CommMessage.php



    namespace AppNotificationsCommunications;

    use IlluminateBusQueueable;
    use IlluminateNotificationsNotification;
    use IlluminateContractsQueueShouldQueue;
    use IlluminateNotificationsMessagesMailMessage;
    use AppMailCommunicationsMessage as Mailable;

    class CommMessage extends Notification implements ShouldQueue
    {

    use Queueable;

    private $communication;

    /**
    * Create a new notification instance.
    *
    * @return void
    */
    public function __construct($communication)
    {
    $this->communication = $communication;

    }

    /**
    * Get the notification's delivery channels.
    *
    * @param mixed $notifiable
    * @return array
    */
    public function via($notifiable)
    {
    return ['mail'];
    }

    /**
    * Get the mail representation of the notification.
    *
    * @param mixed $notifiable
    * @return Mailable
    */
    public function toMail($notifiable)
    {
    return (new Mailable($this->communication))->to($notifiable->email);
    }
    }


    The mailable Message class is:



    Message.php



    namespace AppMailCommunications;

    use IlluminateBusQueueable;
    use IlluminateMailMailable;
    use IlluminateQueueSerializesModels;
    use IlluminateContractsQueueShouldQueue;

    class Message extends Mailable
    {
    use Queueable, SerializesModels;

    /**
    * The appointment instance.
    *
    * @var Appointment
    */
    public $communication;

    /**
    * Create a new message instance.
    *
    * @return void
    */
    public function __construct($communication)
    {
    $this->communication = $communication;

    }

    /**
    * Build the message.
    *
    * @return $this
    */
    public function build()
    {
    $this->replyTo($this->communication->school->email)
    ->markdown('emails.communications.message');

    $this->subject($this->communication->title);

    $this->withSwiftMessage(function ($message) {
    $message->getHeaders()
    ->addTextHeader('X-Mailgun-Variables', json_encode([
    'model_id' => $this->communication->id,
    'model' => get_class($this->communication),
    'email_type' => 11 //Communication message (EmailLogType)
    ]));
    });

    }

    }









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite













      I'm trying to send email to members on my app and I get the following error:




      production.ERROR: Call to undefined method
      IlluminateDatabaseQueryBuilder::routeNotificationFor()
      {"exception":"[object] (BadMethodCallException(code: 0): Call to
      undefined method
      IlluminateDatabaseQueryBuilder::routeNotificationFor() at
      /var/www/vhosts/.../laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)




      I have the members model with the Notifiable trait and the weird issue is that on my local machine the emails are delivered... The problem is on production...



      Any ideas?



      The notifications are fired with:



      Notification::send($members_to_notify, new CommMessage($communication));


      And the CommMessageclass is:



      CommMessage.php



      namespace AppNotificationsCommunications;

      use IlluminateBusQueueable;
      use IlluminateNotificationsNotification;
      use IlluminateContractsQueueShouldQueue;
      use IlluminateNotificationsMessagesMailMessage;
      use AppMailCommunicationsMessage as Mailable;

      class CommMessage extends Notification implements ShouldQueue
      {

      use Queueable;

      private $communication;

      /**
      * Create a new notification instance.
      *
      * @return void
      */
      public function __construct($communication)
      {
      $this->communication = $communication;

      }

      /**
      * Get the notification's delivery channels.
      *
      * @param mixed $notifiable
      * @return array
      */
      public function via($notifiable)
      {
      return ['mail'];
      }

      /**
      * Get the mail representation of the notification.
      *
      * @param mixed $notifiable
      * @return Mailable
      */
      public function toMail($notifiable)
      {
      return (new Mailable($this->communication))->to($notifiable->email);
      }
      }


      The mailable Message class is:



      Message.php



      namespace AppMailCommunications;

      use IlluminateBusQueueable;
      use IlluminateMailMailable;
      use IlluminateQueueSerializesModels;
      use IlluminateContractsQueueShouldQueue;

      class Message extends Mailable
      {
      use Queueable, SerializesModels;

      /**
      * The appointment instance.
      *
      * @var Appointment
      */
      public $communication;

      /**
      * Create a new message instance.
      *
      * @return void
      */
      public function __construct($communication)
      {
      $this->communication = $communication;

      }

      /**
      * Build the message.
      *
      * @return $this
      */
      public function build()
      {
      $this->replyTo($this->communication->school->email)
      ->markdown('emails.communications.message');

      $this->subject($this->communication->title);

      $this->withSwiftMessage(function ($message) {
      $message->getHeaders()
      ->addTextHeader('X-Mailgun-Variables', json_encode([
      'model_id' => $this->communication->id,
      'model' => get_class($this->communication),
      'email_type' => 11 //Communication message (EmailLogType)
      ]));
      });

      }

      }









      share|improve this question

















      I'm trying to send email to members on my app and I get the following error:




      production.ERROR: Call to undefined method
      IlluminateDatabaseQueryBuilder::routeNotificationFor()
      {"exception":"[object] (BadMethodCallException(code: 0): Call to
      undefined method
      IlluminateDatabaseQueryBuilder::routeNotificationFor() at
      /var/www/vhosts/.../laravel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2483)




      I have the members model with the Notifiable trait and the weird issue is that on my local machine the emails are delivered... The problem is on production...



      Any ideas?



      The notifications are fired with:



      Notification::send($members_to_notify, new CommMessage($communication));


      And the CommMessageclass is:



      CommMessage.php



      namespace AppNotificationsCommunications;

      use IlluminateBusQueueable;
      use IlluminateNotificationsNotification;
      use IlluminateContractsQueueShouldQueue;
      use IlluminateNotificationsMessagesMailMessage;
      use AppMailCommunicationsMessage as Mailable;

      class CommMessage extends Notification implements ShouldQueue
      {

      use Queueable;

      private $communication;

      /**
      * Create a new notification instance.
      *
      * @return void
      */
      public function __construct($communication)
      {
      $this->communication = $communication;

      }

      /**
      * Get the notification's delivery channels.
      *
      * @param mixed $notifiable
      * @return array
      */
      public function via($notifiable)
      {
      return ['mail'];
      }

      /**
      * Get the mail representation of the notification.
      *
      * @param mixed $notifiable
      * @return Mailable
      */
      public function toMail($notifiable)
      {
      return (new Mailable($this->communication))->to($notifiable->email);
      }
      }


      The mailable Message class is:



      Message.php



      namespace AppMailCommunications;

      use IlluminateBusQueueable;
      use IlluminateMailMailable;
      use IlluminateQueueSerializesModels;
      use IlluminateContractsQueueShouldQueue;

      class Message extends Mailable
      {
      use Queueable, SerializesModels;

      /**
      * The appointment instance.
      *
      * @var Appointment
      */
      public $communication;

      /**
      * Create a new message instance.
      *
      * @return void
      */
      public function __construct($communication)
      {
      $this->communication = $communication;

      }

      /**
      * Build the message.
      *
      * @return $this
      */
      public function build()
      {
      $this->replyTo($this->communication->school->email)
      ->markdown('emails.communications.message');

      $this->subject($this->communication->title);

      $this->withSwiftMessage(function ($message) {
      $message->getHeaders()
      ->addTextHeader('X-Mailgun-Variables', json_encode([
      'model_id' => $this->communication->id,
      'model' => get_class($this->communication),
      'email_type' => 11 //Communication message (EmailLogType)
      ]));
      });

      }

      }






      laravel email notifications






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 8:25









      Saumini Navaratnam

      4,39511744




      4,39511744










      asked Nov 10 at 0:26









      Dani Pereyra

      3818




      3818
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          This issue was solved. Code has no errors, I was using Supervisor to manage queues and I have forgot to restart it on production server.






          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',
            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%2f53234937%2fgetting-error-routenotificationfor-on-laravel-notifications%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








            up vote
            0
            down vote



            accepted










            This issue was solved. Code has no errors, I was using Supervisor to manage queues and I have forgot to restart it on production server.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              This issue was solved. Code has no errors, I was using Supervisor to manage queues and I have forgot to restart it on production server.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                This issue was solved. Code has no errors, I was using Supervisor to manage queues and I have forgot to restart it on production server.






                share|improve this answer












                This issue was solved. Code has no errors, I was using Supervisor to manage queues and I have forgot to restart it on production server.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 at 10:32









                Dani Pereyra

                3818




                3818






























                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f53234937%2fgetting-error-routenotificationfor-on-laravel-notifications%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







                    Popular posts from this blog

                    Landwehr

                    Reims

                    Schenkenzell