feat: send WhatsApp notification on delivery dispatched

This commit is contained in:
Ghassan Yusuf 2026-05-19 13:19:41 +03:00
parent a64443110a
commit 8303df358f
2 changed files with 34 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use App\Models\SalesOrderItem;
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\Sales\DeliveryDispatchedNotification;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -145,6 +146,10 @@ class DeliveryNoteController extends Controller
} }
}); });
if ($deliveryNote->customer && $deliveryNote->customer->whatsapp_number) {
$deliveryNote->customer->notify(new DeliveryDispatchedNotification($deliveryNote));
}
return redirect()->back()->with('success', 'Delivery note dispatched and stock decremented.'); return redirect()->back()->with('success', 'Delivery note dispatched and stock decremented.');
} }
} }

View File

@ -0,0 +1,29 @@
<?php
namespace App\Notifications\Sales;
use App\Models\DeliveryNote;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use PromoSeven\UltraMessage\UltraMessageChannel;
use PromoSeven\UltraMessage\UltraMessageMessage;
class DeliveryDispatchedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(private DeliveryNote $delivery) {}
public function via(mixed $notifiable): array
{
return [UltraMessageChannel::class];
}
public function toUltraMessage(mixed $notifiable): UltraMessageMessage
{
return UltraMessageMessage::text(
"Dear {$notifiable->name},\n\nYour delivery *#{$this->delivery->delivery_number}* has been dispatched and is on its way.\n\nOrder Reference: {$this->delivery->salesOrder->order_number}\nDispatch Date: {$this->delivery->delivery_date}\n\nThank you for your business."
);
}
}