From 92a2eb120fb7a90dadd31dffe4f77bbcc766ac17 Mon Sep 17 00:00:00 2001 From: Ghassan Yusuf Date: Tue, 19 May 2026 13:02:06 +0300 Subject: [PATCH] feat: add whatsapp_number field to suppliers, customers, users Co-Authored-By: Claude Sonnet 4.6 --- app/Models/Customer.php | 7 +++++- app/Models/Supplier.php | 7 +++++- app/Models/User.php | 6 +++++ ...add_whatsapp_number_to_customers_table.php | 25 +++++++++++++++++++ ...add_whatsapp_number_to_suppliers_table.php | 25 +++++++++++++++++++ ...100_add_whatsapp_number_to_users_table.php | 25 +++++++++++++++++++ 6 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2026_05_19_100059_add_whatsapp_number_to_customers_table.php create mode 100644 database/migrations/2026_05_19_100059_add_whatsapp_number_to_suppliers_table.php create mode 100644 database/migrations/2026_05_19_100100_add_whatsapp_number_to_users_table.php diff --git a/app/Models/Customer.php b/app/Models/Customer.php index bf2307a..9705e62 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -9,7 +9,7 @@ class Customer extends Model { use HasFactory; - protected $fillable = ['name', 'contact_person', 'email', 'phone', 'address', 'tax_number', 'credit_limit', 'outstanding_balance', 'is_active']; + protected $fillable = ['name', 'contact_person', 'email', 'phone', 'whatsapp_number', 'address', 'tax_number', 'credit_limit', 'outstanding_balance', 'is_active']; protected $casts = [ 'credit_limit' => 'decimal:2', @@ -17,6 +17,11 @@ class Customer extends Model 'is_active' => 'boolean', ]; + public function routeNotificationFor(string $channel, mixed $notification = null): ?string + { + return $this->whatsapp_number; + } + public function salesOrders() { return $this->hasMany(SalesOrder::class); diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 09fd0d2..700b3ba 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -12,7 +12,7 @@ class Supplier extends Model protected $fillable = [ 'supplier_code', 'name', 'category', 'contact_person', 'email', 'secondary_email', - 'phone', 'phone2', 'whatsapp', + 'phone', 'phone2', 'whatsapp', 'whatsapp_number', 'address', 'website', 'tax_number', 'credit_terms', 'credit_days', 'is_active', 'remarks', @@ -20,6 +20,11 @@ class Supplier extends Model protected $casts = ['is_active' => 'boolean']; + public function routeNotificationFor(string $channel, mixed $notification = null): ?string + { + return $this->whatsapp_number; + } + public function purchaseOrders() { return $this->hasMany(PurchaseOrder::class); diff --git a/app/Models/User.php b/app/Models/User.php index badbf65..368f00c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -22,6 +22,7 @@ class User extends Authenticatable protected $fillable = [ 'name', 'email', + 'whatsapp_number', 'password', ]; @@ -40,6 +41,11 @@ class User extends Authenticatable * * @return array */ + public function routeNotificationFor(string $channel, mixed $notification = null): ?string + { + return $this->whatsapp_number; + } + protected function casts(): array { return [ diff --git a/database/migrations/2026_05_19_100059_add_whatsapp_number_to_customers_table.php b/database/migrations/2026_05_19_100059_add_whatsapp_number_to_customers_table.php new file mode 100644 index 0000000..d3d38c0 --- /dev/null +++ b/database/migrations/2026_05_19_100059_add_whatsapp_number_to_customers_table.php @@ -0,0 +1,25 @@ +string('whatsapp_number')->nullable()->after('phone'); + }); + } + + public function down(): void + { + Schema::table('customers', function (Blueprint $table) { + $table->dropColumn('whatsapp_number'); + }); + } +}; diff --git a/database/migrations/2026_05_19_100059_add_whatsapp_number_to_suppliers_table.php b/database/migrations/2026_05_19_100059_add_whatsapp_number_to_suppliers_table.php new file mode 100644 index 0000000..4570708 --- /dev/null +++ b/database/migrations/2026_05_19_100059_add_whatsapp_number_to_suppliers_table.php @@ -0,0 +1,25 @@ +string('whatsapp_number')->nullable()->after('phone'); + }); + } + + public function down(): void + { + Schema::table('suppliers', function (Blueprint $table) { + $table->dropColumn('whatsapp_number'); + }); + } +}; diff --git a/database/migrations/2026_05_19_100100_add_whatsapp_number_to_users_table.php b/database/migrations/2026_05_19_100100_add_whatsapp_number_to_users_table.php new file mode 100644 index 0000000..07fcff9 --- /dev/null +++ b/database/migrations/2026_05_19_100100_add_whatsapp_number_to_users_table.php @@ -0,0 +1,25 @@ +string('whatsapp_number')->nullable()->after('email'); + }); + } + + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('whatsapp_number'); + }); + } +};