diff --git a/app/Http/Controllers/Api/CustomerController.php b/app/Http/Controllers/Api/CustomerController.php index f4ce89c..3544bdf 100644 --- a/app/Http/Controllers/Api/CustomerController.php +++ b/app/Http/Controllers/Api/CustomerController.php @@ -18,6 +18,14 @@ class CustomerController extends Controller return response()->json(Customer::with(['address', 'delivery'])->orderBy('name')->get()); } + /** + * Display a listing of the resource. + */ + public function withTrashed(): JsonResponse + { + return response()->json(Customer::with(['address', 'delivery'])->withTrashed()->orderBy('name')->get()); + } + /** * Store a newly created resource in storage. */ @@ -66,4 +74,14 @@ class CustomerController extends Controller return response()->json(null, 204); } + + /** + * Restore the specified resource. + */ + public function restore(int $id): JsonResponse + { + $customer = Customer::withTrashed()->findOrFail($id)->restore(); + + return response()->json($customer); + } } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 4e94a75..e95a1bc 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -99,7 +99,7 @@ class Invoice extends Model */ public function customer(): BelongsTo { - return $this->belongsTo(Customer::class); + return $this->belongsTo(Customer::class)->withTrashed(); } /** diff --git a/lang/de/form.php b/lang/de/form.php index edeb6f0..0183172 100644 --- a/lang/de/form.php +++ b/lang/de/form.php @@ -14,6 +14,7 @@ return [ 'Add' => 'Anlegen', 'Edit' => 'Bearbeiten', 'Delete' => 'Löschen', + 'Restore' => 'Wiederherstellen', 'Save' => 'Speichern', 'Change' => 'Ändern', 'SaveAndContinue' => 'Speichern und Weiter', diff --git a/resources/views/components/restore-icon.blade.php b/resources/views/components/restore-icon.blade.php new file mode 100644 index 0000000..f474c60 --- /dev/null +++ b/resources/views/components/restore-icon.blade.php @@ -0,0 +1,3 @@ + diff --git a/resources/views/customer/index.blade.php b/resources/views/customer/index.blade.php index 09215c4..4a92d1a 100644 --- a/resources/views/customer/index.blade.php +++ b/resources/views/customer/index.blade.php @@ -19,14 +19,15 @@ {{ __("customer.Add new customer by clicking add") }}
-