Make customers deletable and recoverable.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class Invoice extends Model
|
||||
*/
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
return $this->belongsTo(Customer::class)->withTrashed();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user