diff --git a/app/Livewire/Auth/Register.php b/app/Livewire/Auth/Register.php index 1bbb4b6..4b13340 100644 --- a/app/Livewire/Auth/Register.php +++ b/app/Livewire/Auth/Register.php @@ -2,7 +2,10 @@ namespace App\Livewire\Auth; +use App\Jobs\StorePushNotification; use App\Livewire\Forms\Auth\RegisterForm; +use App\Models\PushNotification; +use App\Models\User; use App\Traits\WithToast; use App\Traits\WithUpdatedData; use Illuminate\Support\Str; @@ -80,6 +83,15 @@ public function register() $this->toast('Selamat, akun Anda berhasil didaftarkan. Silakan periksa email Anda untuk melakukan verifikasi.'); + $userIds = User::role(['Developer', 'Owner'])->pluck('id')->toArray(); + StorePushNotification::dispatch( + PushNotification::whereIn('user_id', $userIds)->get(), + [ + 'title' => 'Member Baru', + 'body' => 'Seorang member baru baru saja bergabung. Cek selengkapnya di aplikasi', + ], + ); + $this->redirectIntended('/customer/dashboard/overview', navigate: true); } diff --git a/app/Livewire/Forms/Auth/RegisterForm.php b/app/Livewire/Forms/Auth/RegisterForm.php index d32c0c9..7278b68 100644 --- a/app/Livewire/Forms/Auth/RegisterForm.php +++ b/app/Livewire/Forms/Auth/RegisterForm.php @@ -142,10 +142,10 @@ public function auth() 'type' => PointRecordType::TIER, ]); - auth()->login($user); - $user->assignRole('Customer'); + auth()->login($user); + $user->sendEmailVerificationNotification(); }); }