feat: send WhatsApp notification on delivery dispatched
This commit is contained in:
parent
a64443110a
commit
8303df358f
@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
app/Notifications/Sales/DeliveryDispatchedNotification.php
Normal file
29
app/Notifications/Sales/DeliveryDispatchedNotification.php
Normal 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."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user