feat: send WhatsApp notification on GRN confirmed
This commit is contained in:
parent
358907bbed
commit
639282f707
@ -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.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user