CustomerDelete
This commit is contained in:
@@ -59,7 +59,7 @@ class ManageCustomerController extends Controller
|
||||
|
||||
|
||||
try {
|
||||
$customers_data = IamPrincipal::with('state','contactMessages')->findOrFail($id);
|
||||
$customers_data = IamPrincipal::with('state', 'contactMessages')->findOrFail($id);
|
||||
if ($customers_data->contactMessages->isEmpty()) {
|
||||
Log::info('No contact messages found for customer with ID: ' . $id);
|
||||
}
|
||||
@@ -222,44 +222,44 @@ class ManageCustomerController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 28 May 2024
|
||||
Use : To Get Excel.
|
||||
*/
|
||||
|
||||
|
||||
public function exportSelectedCustomer(Request $request)
|
||||
{
|
||||
try {
|
||||
if ($request->has('all_id')) {
|
||||
return Excel::download(new customer_export, 'Passport_data.xlsx');
|
||||
}
|
||||
|
||||
|
||||
$ids = $request->selected_id;
|
||||
|
||||
|
||||
if (empty($ids)) {
|
||||
return response()->json(['error' => 'No IDs provided for export.'], 400);
|
||||
}
|
||||
|
||||
|
||||
Log::info("Selected IDs for export: " . $ids);
|
||||
|
||||
|
||||
$fileName = 'selected_customer_data.xlsx';
|
||||
|
||||
|
||||
Log::info("Attempting to export selected customers to file: " . $fileName);
|
||||
|
||||
|
||||
return Excel::download(new customer_export_selected($ids), $fileName);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Export failed: ' . $e->getMessage());
|
||||
return response()->json(['error' => 'Export failed. Something went wrong.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
/*
|
||||
Created By : Sayali Parab
|
||||
Created at : 28 May 2024
|
||||
Use : To Deleted Data Restore.
|
||||
@@ -297,4 +297,26 @@ class ManageCustomerController extends Controller
|
||||
return response()->json(['error' => __('auth.something_went_wrong')], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Created By : Sayali parab
|
||||
Created at : 27 June 2024
|
||||
Use : To delete customer details.
|
||||
*/
|
||||
|
||||
public function deleteCustomerUser($id)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$deleteCustomer = IamPrincipal::find($id);
|
||||
// dd($id );
|
||||
$deleteCustomer->delete();
|
||||
DB::commit();
|
||||
return response()->json(['sucess' => true, 'status' => 200]);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error("delete_passport function Load Failed " . $e->getMessage());
|
||||
return response()->json(['success' => false, 'status' => 500, 'message' => __('auth.something_went_wrong')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user