From 03826e41685c3d35a0ebe127b41cbc0276cf2e7b Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 6 Jun 2026 19:03:22 +0530 Subject: [PATCH] Added mail logic for visitor entry create page --- .../Pages/CreateVisitorEntry.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php b/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php index e274daf..e25f60e 100644 --- a/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php +++ b/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php @@ -10,6 +10,8 @@ use Filament\Actions\Action; use Filament\Resources\Pages\CreateRecord; use Illuminate\Support\Facades\Storage; use Livewire\Attributes\On; +use App\Mail\VisitorMail; +use Illuminate\Support\Facades\Mail; class CreateVisitorEntry extends CreateRecord { @@ -118,6 +120,21 @@ class CreateVisitorEntry extends CreateRecord ]; } + protected function afterCreate(): void + { + $visitor = $this->record; + + $employee = EmployeeMaster::find($visitor->employee_master_id); + + if ($employee && !empty($employee->email)) { + Mail::to($employee->email) + ->send(new VisitorMail($visitor)); // or ->send() + } + else{ + \Log::warning('No email found for employee ID: ' . $visitor->employee_master_id); + } + } + protected function getRedirectUrl(): string { return $this->getResource()::getUrl('view', ['record' => $this->record]);