Skip to content

Commit

Permalink
readme and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebarlow committed Feb 25, 2023
1 parent cd5f1c3 commit 8ffb541
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.2.0] - 2023-02-25

* Removed `public $user` from component and changed loading of announcements to prevent user model data exposure. [PR #22](https://github.com/mikebarlow/megaphone/pull/22)
* Added ability to pass in the notifiableId via component render

## [1.1.0] - 2022-12-27

* Improvement: New SVG Bell Icon [PR #17](https://github.com/mikebarlow/megaphone/pull/17)
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ This will clear any "read" Megaphone notifications older than 2 weeks old. This

The 2-week time limit for old notifications is controlled via the Megaphone config file, `config('megaphone.clearAfter')`. So should you wish to alter this cut off point, simply change this value to either extend or shorten the cut off.

## Changing Notifiable Model

Because notifications can be attached to any model via the `Notifiable` trait, Megaphone too can be attached to any model providing the model also has the `Notifiable` trait attached.

As default, Megaphone assumes you will be attaching it to the standard Laravel User model and when loading notifications, it will attempt to retrieve the ID of the logged in user from the Request object.

If you are wanting to attach Megaphone to a Team model for example, change the `model` attribute of the published megaphone config file, `megaphone.php`.

When rendering the Megaphone component, you will then need to pass in the ID of the notifiable model into the component so Megaphone can load the correct notifications

```html
<livewire:megaphone :notifiableId="$user->team->id"></livewire:megaphone>
```



## Testing

If you wish to run the tests, clone out the repository
Expand Down

0 comments on commit 8ffb541

Please sign in to comment.