mirror of
https://github.com/brufdev/many-notes.git
synced 2026-05-14 22:28:26 -05:00
Add vault ID to collaboration notifications
This commit is contained in:
@@ -33,14 +33,16 @@ final class CollaborationInvite extends Component
|
||||
$currentUser = auth()->user();
|
||||
$this->vault->collaborators()->updateExistingPivot($currentUser->id, ['accepted' => 1]);
|
||||
$notifications = $currentUser->notifications()->where('type', CollaborationInvited::class)->get();
|
||||
|
||||
foreach ($notifications as $notification) {
|
||||
if ($notification->data['vault_id'] === $this->vault->id) {
|
||||
$notification->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->vault->user;
|
||||
$user->notify(new CollaborationAccepted($currentUser));
|
||||
$user->notify(new CollaborationAccepted($this->vault, $currentUser));
|
||||
$this->dispatch('notifications-refresh');
|
||||
$this->dispatch('vaults-refresh');
|
||||
$this->closeModal();
|
||||
@@ -53,14 +55,16 @@ final class CollaborationInvite extends Component
|
||||
$currentUser = auth()->user();
|
||||
$this->vault->collaborators()->detach($currentUser->id);
|
||||
$notifications = $currentUser->notifications()->where('type', CollaborationInvited::class)->get();
|
||||
|
||||
foreach ($notifications as $notification) {
|
||||
if ($notification->data['vault_id'] === $this->vault->id) {
|
||||
$notification->delete();
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->vault->user;
|
||||
$user->notify(new CollaborationDeclined($currentUser));
|
||||
$user->notify(new CollaborationDeclined($this->vault, $currentUser));
|
||||
$this->dispatch('notifications-refresh');
|
||||
$this->closeModal();
|
||||
$this->dispatch('toast', message: __('Invite declined'), type: 'success');
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Vault;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
@@ -16,6 +17,7 @@ final class CollaborationAccepted extends Notification
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(
|
||||
private Vault $vault,
|
||||
private User $user,
|
||||
) {
|
||||
//
|
||||
@@ -39,6 +41,7 @@ final class CollaborationAccepted extends Notification
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'vault_id' => $this->vault->id,
|
||||
'user_id' => $this->user->id,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Vault;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
@@ -16,6 +17,7 @@ final class CollaborationDeclined extends Notification
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(
|
||||
private Vault $vault,
|
||||
private User $user,
|
||||
) {
|
||||
//
|
||||
@@ -39,6 +41,7 @@ final class CollaborationDeclined extends Notification
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'vault_id' => $this->vault->id,
|
||||
'user_id' => $this->user->id,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user