Merge pull request 'changed logic in edit transporter bid' (#150) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Reviewed-on: #150
This commit was merged in pull request #150.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\RfqTransporterBidResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RfqTransporterBidResource;
|
||||
use App\Models\RfqTransporterBid;
|
||||
use App\Models\SpotRateTransportMaster;
|
||||
use App\Models\User;
|
||||
use App\Notifications\PushAlertNotification;
|
||||
use Filament\Actions;
|
||||
@@ -24,48 +25,78 @@ class EditRfqTransporterBid extends EditRecord
|
||||
// dd($this->record);
|
||||
|
||||
$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')
|
||||
->pluck('id')
|
||||
->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();
|
||||
|
||||
if ($currentUser && ! $recipients1->contains('id', $currentUser->id)) {
|
||||
$recipients1->push($currentUser);
|
||||
}
|
||||
// if ($currentUser && ! $recipients1->contains('id', $currentUser->id)) {
|
||||
// $recipients1->push($currentUser);
|
||||
// }
|
||||
|
||||
if ($currentUser && ! $recipients->contains('id', $currentUser->id)) {
|
||||
$recipients->push($currentUser);
|
||||
}
|
||||
// if ($currentUser && ! $recipients->contains('id', $currentUser->id)) {
|
||||
// $recipients->push($currentUser);
|
||||
// }
|
||||
|
||||
// $user1 = Filament::auth()->user();
|
||||
|
||||
|
||||
$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()
|
||||
->title('Rank Updated')
|
||||
->body("{$currentUser->name} current rank is #{$rank}")
|
||||
->success()
|
||||
->sendToDatabase($recipients);
|
||||
->title('Rank Updated')
|
||||
->body("{$currentUser->name} current rank is #{$rank}")
|
||||
->success()
|
||||
->sendToDatabase($users);
|
||||
|
||||
\Log::info('Notification sent', [
|
||||
'rank' => $rank,
|
||||
'recipients' => $recipients->pluck('id'),
|
||||
]);
|
||||
// foreach ($recipients1 as $user) {
|
||||
// $user->notify(
|
||||
// new PushAlertNotification(
|
||||
// 'Rank Updated',
|
||||
// $body
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
|
||||
foreach ($recipients1 as $user) {
|
||||
$user->notify(
|
||||
new PushAlertNotification(
|
||||
'Rank Updated',
|
||||
$body
|
||||
)
|
||||
);
|
||||
foreach ($users as $user) {
|
||||
if ($user->pushSubscriptions()->exists()) {
|
||||
$user->notify(
|
||||
new PushAlertNotification(
|
||||
'Rank Updated',
|
||||
$body
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user