record; // Calculate rank based on total_freight_charge $rank = RfqTransporterBid::where('request_quotation_id', $record->request_quotation_id) ->orderBy('total_freight_charge') ->pluck('id') ->search($record->id) + 1; $currentUser = Filament::auth()->user(); // Get recipients $recipients = User::whereHas('roles', function ($q) { $q->whereIn('name', ['Super Admin', 'Rfq Supervisor']) ->where('guard_name', 'web'); })->get(); // Exclude creator $recipients = $recipients->where('id', '!=', $currentUser->id); $body = "{$currentUser->name} added a new bid. Current rank is #{$rank}"; // Filament DB notification Notification::make() ->title('New Bid Added') ->body($body) ->success() ->sendToDatabase($recipients); // Push notification foreach ($recipients as $user) { $user->notify( new PushAlertNotification( 'New Bid Added', $body ) ); } \Log::info('Create bid notification sent', [ 'bid_id' => $record->id, 'rank' => $rank, 'recipients' => $recipients->pluck('id'), ]); } }