changed logic in edit transporter bid
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 17s
Laravel Pint / pint (pull_request) Failing after 3m47s
Laravel Larastan / larastan (pull_request) Failing after 4m43s

This commit is contained in:
dhanabalan
2026-01-27 14:10:20 +05:30
parent cd553651f3
commit dc445b17f5

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Resources\RfqTransporterBidResource\Pages;
use App\Filament\Resources\RfqTransporterBidResource; use App\Filament\Resources\RfqTransporterBidResource;
use App\Models\RfqTransporterBid; use App\Models\RfqTransporterBid;
use App\Models\SpotRateTransportMaster;
use App\Models\User; use App\Models\User;
use App\Notifications\PushAlertNotification; use App\Notifications\PushAlertNotification;
use Filament\Actions; use Filament\Actions;
@@ -24,48 +25,78 @@ class EditRfqTransporterBid extends EditRecord
// dd($this->record); // dd($this->record);
$rank = RfqTransporterBid::where('request_quotation_id', $this->record->request_quotation_id) $rank = RfqTransporterBid::where('request_quotation_id', $this->record->request_quotation_id)
->where('spot_rate_transport_master_id', $this->record->spot_rate_transport_master_id)
->orderBy('total_freight_charge') ->orderBy('total_freight_charge')
->pluck('id') ->pluck('id')
->search($this->record->id) + 1; ->search($this->record->id) + 1;
$recipients = User::role(['Super Admin', 'Rfq Supervisor', 'TransporterBid Employee'])->get(); $spotRate = SpotRateTransportMaster::findOrFail(
$this->record->spot_rate_transport_master_id
);
$recipients1 = User::role(['Super Admin', 'Rfq Supervisor', 'TransporterBid Employee'])->whereHas('pushSubscriptions')->get(); $userNames = json_decode($spotRate->user_name, true);
if (!is_array($userNames)) {
$userNames = [];
}
$users = User::whereIn('name', $userNames)->get();
// $recipients = User::role(['Super Admin', 'Rfq Supervisor', 'TransporterBid Employee'])->get();
// $recipients1 = User::role(['Super Admin', 'Rfq Supervisor', 'TransporterBid Employee'])->whereHas('pushSubscriptions')->get();
$currentUser = Filament::auth()->user(); $currentUser = Filament::auth()->user();
if ($currentUser && ! $recipients1->contains('id', $currentUser->id)) { // if ($currentUser && ! $recipients1->contains('id', $currentUser->id)) {
$recipients1->push($currentUser); // $recipients1->push($currentUser);
} // }
if ($currentUser && ! $recipients->contains('id', $currentUser->id)) { // if ($currentUser && ! $recipients->contains('id', $currentUser->id)) {
$recipients->push($currentUser); // $recipients->push($currentUser);
} // }
// $user1 = Filament::auth()->user(); // $user1 = Filament::auth()->user();
$body = "{$currentUser->name} current rank is #{$rank}"; $body = "{$currentUser->name} current rank is #{$rank}";
// Notification::make()
// ->title('Rank Updated')
// ->body("{$currentUser->name} current rank is #{$rank}")
// ->success()
// ->sendToDatabase($recipients);
// \Log::info('Notification sent', [
// 'rank' => $rank,
// 'recipients' => $recipients->pluck('id'),
// ]);
Notification::make() Notification::make()
->title('Rank Updated') ->title('Rank Updated')
->body("{$currentUser->name} current rank is #{$rank}") ->body("{$currentUser->name} current rank is #{$rank}")
->success() ->success()
->sendToDatabase($recipients); ->sendToDatabase($users);
\Log::info('Notification sent', [ // foreach ($recipients1 as $user) {
'rank' => $rank, // $user->notify(
'recipients' => $recipients->pluck('id'), // new PushAlertNotification(
]); // 'Rank Updated',
// $body
// )
// );
// }
foreach ($recipients1 as $user) { foreach ($users as $user) {
$user->notify( if ($user->pushSubscriptions()->exists()) {
new PushAlertNotification( $user->notify(
'Rank Updated', new PushAlertNotification(
$body 'Rank Updated',
) $body
); )
);
}
} }