Make customers deletable and recoverable.

This commit is contained in:
2025-02-13 13:00:44 +01:00
parent d5961d202f
commit 71e6a74120
6 changed files with 122 additions and 22 deletions

View File

@@ -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);
}
}

View File

@@ -99,7 +99,7 @@ class Invoice extends Model
*/
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);
return $this->belongsTo(Customer::class)->withTrashed();
}
/**