diff --git a/app/Http/Controllers/Api/InvoiceController.php b/app/Http/Controllers/Api/InvoiceController.php
index 18dac0c..6aa401e 100644
--- a/app/Http/Controllers/Api/InvoiceController.php
+++ b/app/Http/Controllers/Api/InvoiceController.php
@@ -55,9 +55,31 @@ class InvoiceController extends Controller
/**
* Update the specified resource in storage.
*/
- public function update(Request $request, Invoice $invoice)
+ public function update(Request $request, Invoice $invoice): JsonResponse
{
- //
+ $invoiceData = $request->validate([
+ 'customer_id' => 'required|integer|exists:customers,id',
+ 'address_id' => 'required|integer|exists:addresses,id',
+ 'delivery_id' => 'nullable|integer|exists:addresses,id',
+ 'tax' => 'required|numeric',
+ 'sum' => 'required|numeric',
+ ]);
+
+ $invoice->update($invoiceData);
+ $invoice->items()->delete();
+
+ return response()->json($invoice);
+ }
+
+ public function state(Request $request, Invoice $invoice): JsonResponse
+ {
+ $invoiceData = $request->validate([
+ 'status' => 'required|string'
+ ]);
+
+ $invoice->update($invoiceData);
+
+ return response()->json($invoice);
}
/**
diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php
index 187d236..ce64bff 100644
--- a/app/Http/Controllers/InvoiceController.php
+++ b/app/Http/Controllers/InvoiceController.php
@@ -34,9 +34,9 @@ class InvoiceController extends Controller
/**
* Show the form for editing the specified resource.
*/
- public function edit(Invoice $invoice)
+ public function edit(Invoice $invoice): View
{
- //
+ return view('invoice.edit', ['invoice' => $invoice]);
}
/**
diff --git a/resources/views/invoice/edit.blade.php b/resources/views/invoice/edit.blade.php
new file mode 100644
index 0000000..d3b6db0
--- /dev/null
+++ b/resources/views/invoice/edit.blade.php
@@ -0,0 +1,489 @@
+
+ {{ __("invoice.Select your customer and address") }}
+
+ {{ __("invoice.Select your customer's address") }}
+
+ {{ __("invoice.Enter your invoice items. Click add for an additional invoice item.") }}
+
+ {{ __('invoice.Edit invoice') }}
+
+
+ {{ __('invoice.Select customer') }}
+
+
+ {{ __('invoice.Select address') }}
+
+
+ {{ __('invoice.Invoice items') }}
+
+
- {{ __("invoice.Send email to your customer with attachments.") }} -
-+ {{ __("invoice.Send email to your customer with attachments manually.") }} +
+