team invitation notification with broadcasting

This commit is contained in:
Čarodej
2022-03-10 16:23:13 +01:00
parent 64e80d387b
commit 9ae2d54a5e
50 changed files with 331 additions and 201 deletions

View File

@@ -1,6 +1,7 @@
<?php
namespace Domain\Teams\Actions;
use App\Users\Models\User;
use Domain\Folders\Models\Folder;
use Spatie\QueueableAction\QueueableAction;
use Illuminate\Support\Facades\Notification;
@@ -25,9 +26,19 @@ class InviteMembersIntoTeamFolderAction
'inviter_id' => $folder->user_id,
]);
// Invite user
Notification::route('mail', $member['email'])
->notify(new InvitationIntoTeamFolder($folder, $invitation));
// Get user
$user = User::where('email', $member['email'])->first();
// Invite native user
if ($user) {
$user->notify(new InvitationIntoTeamFolder($folder, $invitation));
}
// Invite guest
if (! $user) {
Notification::route('mail', $member['email'])
->notify(new InvitationIntoTeamFolder($folder, $invitation));
}
});
}
}