Files
mtdb_movie/common/Workspaces/Actions/DeleteInviteNotification.php
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

31 lines
783 B
PHP
Executable File

<?php
namespace Common\Workspaces\Actions;
use App\Models\User;
use Common\Workspaces\Notifications\WorkspaceInvitation;
use Common\Workspaces\WorkspaceInvite;
use Illuminate\Notifications\DatabaseNotification;
class DeleteInviteNotification
{
public function execute(WorkspaceInvite $invite, User $user): void
{
$notifications = $user
->notifications()
->where('type', WorkspaceInvitation::class)
->limit(20)
->get();
$notification = $notifications->first(function (
DatabaseNotification $notification,
) use ($invite) {
return $notification->data['inviteId'] === $invite->id;
});
if ($notification) {
$notification->delete();
}
}
}