Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel's notifications data formats for broadcast driver and database driver are different. #141

Closed
lancepioch opened this issue Aug 31, 2017 · 1 comment

Comments

@lancepioch
Copy link
Contributor

From @sullyfischer's comment:

Laravel's notifications data formats for broadcast driver and database driver are different. This causes an error when a notification is broadcasted. But after a refresh user can load the same notification and it works just fine (because this time it's being fetched from database).

The production server however is working fine now and that's because back then I used to push /vendor files and in my local vendors files I've done this modification in Laravel core that takes care of it:
In BroadcastNotificationCreated.php:

   /**
    * Get the data that should be sent with the broadcasted event.
    *
    * @return array
    */
   public function broadcastWith()
   {
       return [
       	'data' => $this->data,
           'id' => $this->notification->id,
           'type' => get_class($this->notification),
           'created_at' => Carbon::now(),
           'read_at' => null
       ];

       // return array_merge($this->data, [
       //     'id' => $this->notification->id,
       //     'type' => get_class($this->notification),
       // ]);
   }

Can you think of a "right way" for this?

@saleh-old
Copy link
Contributor

Maybe we should post this in Laravel forums as well?

saleh-old added a commit that referenced this issue Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants