send notification user method working
This commit is contained in:
parent
14f409abec
commit
9752fffae6
7 changed files with 67 additions and 18 deletions
|
|
@ -3,5 +3,8 @@
|
|||
Kirby::plugin('adrienpayet/pdc-notifications', [
|
||||
'routes' => [
|
||||
require(__DIR__ . '/routes/mark-as-read.php'),
|
||||
],
|
||||
'userMethods' => [
|
||||
'sendNotification' => require(__DIR__ . '/user-methods/send.php')
|
||||
]
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
return function ($group, $data) {
|
||||
return function ($group, $item) {
|
||||
foreach (kirby()->users()->not($this) as $otherUser) {
|
||||
try {
|
||||
$notifications = $otherUser->notifications()->isNotEmpty()
|
||||
|
|
@ -10,11 +10,8 @@ return function ($group, $data) {
|
|||
if (!isset($notifications[$group])) {
|
||||
$notifications[$group] = [];
|
||||
}
|
||||
|
||||
|
||||
$data['isRead'] = false;
|
||||
|
||||
$notifications[$group][$data['id']] = $data;
|
||||
$notifications[$group][$item->id()] = $item->toArray();
|
||||
|
||||
$otherUser->update([
|
||||
'notifications' => $notifications
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue