Skip to content

Commit e010831

Browse files
[12.x] Add readNotifications relationship method (#10638)
* Add readNotifications relationship method * Update notifications.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 09993c1 commit e010831

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

notifications.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,16 @@ foreach ($user->unreadNotifications as $notification) {
991991
}
992992
```
993993

994+
If you want to retrieve only the "read" notifications, you may use the `readNotifications` relationship:
995+
996+
```php
997+
$user = App\Models\User::find(1);
998+
999+
foreach ($user->readNotifications as $notification) {
1000+
echo $notification->type;
1001+
}
1002+
```
1003+
9941004
> [!NOTE]
9951005
> To access your notifications from your JavaScript client, you should define a notification controller for your application which returns the notifications for a notifiable entity, such as the current user. You may then make an HTTP request to that controller's URL from your JavaScript client.
9961006

0 commit comments

Comments
 (0)