feat: send WhatsApp notification on GRN confirmed

This commit is contained in:
Ghassan Yusuf 2026-05-19 13:19:27 +03:00
parent 358907bbed
commit 639282f707
2 changed files with 33 additions and 0 deletions

View File

@ -9,6 +9,7 @@ use App\Models\PurchaseOrder;
use App\Models\StockLevel; use App\Models\StockLevel;
use App\Models\StockMovement; use App\Models\StockMovement;
use App\Models\Warehouse; use App\Models\Warehouse;
use App\Notifications\Purchase\GoodsReceiptConfirmedNotification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -145,6 +146,9 @@ class GoodsReceiptNoteController extends Controller
} }
}); });
$storeManagers = \App\Models\User::role('Store Manager')->whereNotNull('whatsapp_number')->get();
\Illuminate\Support\Facades\Notification::send($storeManagers, new GoodsReceiptConfirmedNotification($grn));
return redirect()->back()->with('success', 'GRN confirmed and stock updated.'); return redirect()->back()->with('success', 'GRN confirmed and stock updated.');
} }
} }

View File

@ -0,0 +1,29 @@
<?php
namespace App\Notifications\Purchase;
use App\Models\GoodsReceiptNote;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use PromoSeven\UltraMessage\UltraMessageChannel;
use PromoSeven\UltraMessage\UltraMessageMessage;
class GoodsReceiptConfirmedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(private GoodsReceiptNote $grn) {}
public function via(mixed $notifiable): array
{
return [UltraMessageChannel::class];
}
public function toUltraMessage(mixed $notifiable): UltraMessageMessage
{
return UltraMessageMessage::text(
"GRN *#{$this->grn->grn_number}* has been confirmed and goods received.\n\nPO Reference: {$this->grn->purchaseOrder->po_number}\nDate: {$this->grn->received_date}"
);
}
}