feat: add whatsapp_number field to supplier and customer forms

This commit is contained in:
Ghassan Yusuf 2026-05-19 13:09:32 +03:00
parent 34e095526f
commit 12751ab39c
6 changed files with 71 additions and 19 deletions

View File

@ -40,14 +40,15 @@ class SupplierController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$request->validate([ $request->validate([
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'credit_days' => 'nullable|integer|min:0', 'credit_days' => 'nullable|integer|min:0',
'whatsapp_number' => ['nullable', 'string', 'max:20'],
]); ]);
Supplier::create(array_merge( Supplier::create(array_merge(
$request->only([ $request->only([
'supplier_code', 'name', 'category', 'contact_person', 'supplier_code', 'name', 'category', 'contact_person',
'email', 'secondary_email', 'phone', 'phone2', 'whatsapp', 'email', 'secondary_email', 'phone', 'phone2', 'whatsapp', 'whatsapp_number',
'address', 'website', 'tax_number', 'credit_terms', 'credit_days', 'remarks', 'address', 'website', 'tax_number', 'credit_terms', 'credit_days', 'remarks',
]), ]),
['is_active' => (bool) $request->input('is_active', 1)] ['is_active' => (bool) $request->input('is_active', 1)]
@ -69,15 +70,16 @@ class SupplierController extends Controller
public function update(Request $request, Supplier $supplier) public function update(Request $request, Supplier $supplier)
{ {
$request->validate([ $request->validate([
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'credit_days' => 'nullable|integer|min:0', 'credit_days' => 'nullable|integer|min:0',
'is_active' => 'nullable', 'is_active' => 'nullable',
'whatsapp_number' => ['nullable', 'string', 'max:20'],
]); ]);
$supplier->update(array_merge( $supplier->update(array_merge(
$request->only([ $request->only([
'supplier_code', 'name', 'category', 'contact_person', 'supplier_code', 'name', 'category', 'contact_person',
'email', 'secondary_email', 'phone', 'phone2', 'whatsapp', 'email', 'secondary_email', 'phone', 'phone2', 'whatsapp', 'whatsapp_number',
'address', 'website', 'tax_number', 'credit_terms', 'credit_days', 'remarks', 'address', 'website', 'tax_number', 'credit_terms', 'credit_days', 'remarks',
]), ]),
['is_active' => (bool) $request->input('is_active', 0)] ['is_active' => (bool) $request->input('is_active', 0)]

View File

@ -22,14 +22,21 @@ class CustomerController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$request->validate([ $validated = $request->validate([
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'email' => 'nullable|email|max:255', 'email' => 'nullable|email|max:255',
'phone' => 'nullable|string|max:50', 'phone' => 'nullable|string|max:50',
'address' => 'nullable|string', 'whatsapp_number' => 'nullable|string|max:20',
'address' => 'nullable|string',
'contact_person' => 'nullable|string|max:255',
'tax_number' => 'nullable|string|max:50',
'credit_limit' => 'nullable|numeric|min:0',
'is_active' => 'nullable|boolean',
]); ]);
Customer::create($request->all()); $validated['is_active'] = (bool) $request->input('is_active', 1);
Customer::create($validated);
return redirect()->route('sales.customers.index')->with('success', 'Customer created successfully.'); return redirect()->route('sales.customers.index')->with('success', 'Customer created successfully.');
} }
@ -46,14 +53,21 @@ class CustomerController extends Controller
public function update(Request $request, Customer $customer) public function update(Request $request, Customer $customer)
{ {
$request->validate([ $validated = $request->validate([
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'email' => 'nullable|email|max:255', 'email' => 'nullable|email|max:255',
'phone' => 'nullable|string|max:50', 'phone' => 'nullable|string|max:50',
'address' => 'nullable|string', 'whatsapp_number' => 'nullable|string|max:20',
'address' => 'nullable|string',
'contact_person' => 'nullable|string|max:255',
'tax_number' => 'nullable|string|max:50',
'credit_limit' => 'nullable|numeric|min:0',
'is_active' => 'nullable|boolean',
]); ]);
$customer->update($request->all()); $validated['is_active'] = (bool) $request->input('is_active', 0);
$customer->update($validated);
return redirect()->route('sales.customers.index')->with('success', 'Customer updated successfully.'); return redirect()->route('sales.customers.index')->with('success', 'Customer updated successfully.');
} }

View File

@ -43,6 +43,15 @@
<input type="text" name="phone" value="{{ old('phone') }}" class="form-input"> <input type="text" name="phone" value="{{ old('phone') }}" class="form-input">
</div> </div>
<div>
<label class="form-label">WhatsApp Number</label>
<input type="text" name="whatsapp_number"
value="{{ old('whatsapp_number', '') }}"
placeholder="+971501234567"
class="form-input">
<p style="font-size:12px;color:#6b7280;margin-top:4px;">International format. Used for WhatsApp notifications.</p>
</div>
<div> <div>
<label class="form-label">Tax Number</label> <label class="form-label">Tax Number</label>
<input type="text" name="tax_number" value="{{ old('tax_number') }}" class="form-input"> <input type="text" name="tax_number" value="{{ old('tax_number') }}" class="form-input">

View File

@ -44,6 +44,15 @@
<input type="text" name="phone" value="{{ old('phone', $supplier->phone) }}" class="form-input"> <input type="text" name="phone" value="{{ old('phone', $supplier->phone) }}" class="form-input">
</div> </div>
<div>
<label class="form-label">WhatsApp Number</label>
<input type="text" name="whatsapp_number"
value="{{ old('whatsapp_number', $supplier->whatsapp_number ?? '') }}"
placeholder="+971501234567"
class="form-input">
<p style="font-size:12px;color:#6b7280;margin-top:4px;">International format. Used for WhatsApp notifications.</p>
</div>
<div> <div>
<label class="form-label">Tax Number</label> <label class="form-label">Tax Number</label>
<input type="text" name="tax_number" value="{{ old('tax_number', $supplier->tax_number) }}" class="form-input"> <input type="text" name="tax_number" value="{{ old('tax_number', $supplier->tax_number) }}" class="form-input">

View File

@ -43,6 +43,15 @@
<input type="text" name="phone" value="{{ old('phone') }}" class="form-input"> <input type="text" name="phone" value="{{ old('phone') }}" class="form-input">
</div> </div>
<div>
<label class="form-label">WhatsApp Number</label>
<input type="text" name="whatsapp_number"
value="{{ old('whatsapp_number', '') }}"
placeholder="+971501234567"
class="form-input">
<p style="font-size:12px;color:#6b7280;margin-top:4px;">International format. Used for WhatsApp notifications.</p>
</div>
<div> <div>
<label class="form-label">Tax Number</label> <label class="form-label">Tax Number</label>
<input type="text" name="tax_number" value="{{ old('tax_number') }}" class="form-input"> <input type="text" name="tax_number" value="{{ old('tax_number') }}" class="form-input">

View File

@ -44,6 +44,15 @@
<input type="text" name="phone" value="{{ old('phone', $customer->phone) }}" class="form-input"> <input type="text" name="phone" value="{{ old('phone', $customer->phone) }}" class="form-input">
</div> </div>
<div>
<label class="form-label">WhatsApp Number</label>
<input type="text" name="whatsapp_number"
value="{{ old('whatsapp_number', $customer->whatsapp_number ?? '') }}"
placeholder="+971501234567"
class="form-input">
<p style="font-size:12px;color:#6b7280;margin-top:4px;">International format. Used for WhatsApp notifications.</p>
</div>
<div> <div>
<label class="form-label">Tax Number</label> <label class="form-label">Tax Number</label>
<input type="text" name="tax_number" value="{{ old('tax_number', $customer->tax_number) }}" class="form-input"> <input type="text" name="tax_number" value="{{ old('tax_number', $customer->tax_number) }}" class="form-input">