From add011790cc7ffb7fcf6e222368d35c18e2ff80a Mon Sep 17 00:00:00 2001 From: Ghassan Yusuf Date: Tue, 19 May 2026 13:29:28 +0300 Subject: [PATCH] fix: add Notifiable trait to Supplier and Customer, add null guards to notification messages --- app/Models/Customer.php | 3 ++- app/Models/Supplier.php | 3 ++- .../Production/ProductionOrderCompletedNotification.php | 2 +- .../Purchase/GoodsReceiptConfirmedNotification.php | 2 +- .../Purchase/PurchaseOrderConfirmedNotification.php | 2 +- app/Notifications/Sales/DeliveryDispatchedNotification.php | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 9705e62..ca67afe 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -4,10 +4,11 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Notifications\Notifiable; class Customer extends Model { - use HasFactory; + use HasFactory, Notifiable; protected $fillable = ['name', 'contact_person', 'email', 'phone', 'whatsapp_number', 'address', 'tax_number', 'credit_limit', 'outstanding_balance', 'is_active']; diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 700b3ba..65c5f46 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -4,10 +4,11 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Notifications\Notifiable; class Supplier extends Model { - use HasFactory; + use HasFactory, Notifiable; protected $fillable = [ 'supplier_code', 'name', 'category', diff --git a/app/Notifications/Production/ProductionOrderCompletedNotification.php b/app/Notifications/Production/ProductionOrderCompletedNotification.php index f7c2dcf..132d370 100644 --- a/app/Notifications/Production/ProductionOrderCompletedNotification.php +++ b/app/Notifications/Production/ProductionOrderCompletedNotification.php @@ -23,7 +23,7 @@ class ProductionOrderCompletedNotification extends Notification implements Shoul public function toUltraMessage(mixed $notifiable): UltraMessageMessage { return UltraMessageMessage::text( - "✅ *Production Complete*\n\nProduction Order *#{$this->order->order_number}* has been completed.\n\nProduct: {$this->order->product->item_name}\nQuantity: {$this->order->quantity_to_produce}\nCompleted: {$this->order->completion_date->format('d M Y')}" + "✅ *Production Complete*\n\nProduction Order *#{$this->order->order_number}* has been completed.\n\nProduct: {$this->order->product?->item_name ?? 'N/A'}\nQuantity: {$this->order->quantity_to_produce}\nCompleted: {$this->order->completion_date?->format('d M Y') ?? now()->format('d M Y')}" ); } } diff --git a/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php b/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php index 025b362..0a1febf 100644 --- a/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php +++ b/app/Notifications/Purchase/GoodsReceiptConfirmedNotification.php @@ -23,7 +23,7 @@ class GoodsReceiptConfirmedNotification extends Notification implements ShouldQu 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->format('d M Y')}" + "GRN *#{$this->grn->grn_number}* has been confirmed and goods received.\n\nPO Reference: {$this->grn->purchaseOrder?->po_number ?? 'N/A'}\nDate: {$this->grn->received_date->format('d M Y')}" ); } } diff --git a/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php b/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php index ca0db0d..c75c67f 100644 --- a/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php +++ b/app/Notifications/Purchase/PurchaseOrderConfirmedNotification.php @@ -23,7 +23,7 @@ class PurchaseOrderConfirmedNotification extends Notification implements ShouldQ public function toUltraMessage(mixed $notifiable): UltraMessageMessage { return UltraMessageMessage::text( - "Dear {$notifiable->name},\n\nPurchase Order *#{$this->order->po_number}* has been confirmed.\n\nTotal Amount: {$this->order->total_amount}\nExpected Delivery: {$this->order->expected_delivery_date}\n\nThank you." + "Dear {$notifiable->name},\n\nPurchase Order *#{$this->order->po_number}* has been placed.\n\nTotal Amount: {$this->order->total_amount}\nExpected Delivery: {$this->order->expected_delivery_date}\n\nThank you." ); } } diff --git a/app/Notifications/Sales/DeliveryDispatchedNotification.php b/app/Notifications/Sales/DeliveryDispatchedNotification.php index b38d77e..aece9c2 100644 --- a/app/Notifications/Sales/DeliveryDispatchedNotification.php +++ b/app/Notifications/Sales/DeliveryDispatchedNotification.php @@ -23,7 +23,7 @@ class DeliveryDispatchedNotification extends Notification implements ShouldQueue 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." + "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 ?? 'N/A'}\nDispatch Date: {$this->delivery->delivery_date->format('d M Y')}\n\nThank you for your business." ); } }