From c92620bca28fc692642d066ec5cc563d438716d8 Mon Sep 17 00:00:00 2001 From: sayaliparab Date: Mon, 17 Jun 2024 13:43:39 +0530 Subject: [PATCH] Export date --- app/Exports/customer_export.php | 2 +- app/Exports/customer_export_selected.php | 4 +-- .../Admin/ManageCustomerController.php | 27 +++++-------------- .../manage_customer/customer.blade.php | 2 +- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/app/Exports/customer_export.php b/app/Exports/customer_export.php index 70c81ba..42ea15e 100644 --- a/app/Exports/customer_export.php +++ b/app/Exports/customer_export.php @@ -30,7 +30,7 @@ class customer_export implements FromCollection , WithHeadings 'first_name' => $customer->first_name, 'last_name' => $customer->last_name, 'email_address' => $customer->email_address, - 'date_of_birth' => $customer->date_of_birth, + 'date_of_birth'=> \Carbon\Carbon::parse($customer->date_of_birth)->format('m-d-Y'), 'state_xid' => $customer->state->name ?? '', // Access the state name and handle null 'phone_number' => $customer->phone_number, ]; diff --git a/app/Exports/customer_export_selected.php b/app/Exports/customer_export_selected.php index fdad05f..56aaa48 100644 --- a/app/Exports/customer_export_selected.php +++ b/app/Exports/customer_export_selected.php @@ -42,7 +42,7 @@ class customer_export_selected implements FromCollection, WithHeadings 'first_name' => $customer->first_name, 'last_name' => $customer->last_name, 'email_address' => $customer->email_address, - 'date_of_birth' => $customer->date_of_birth, + 'date_of_birth' => \Carbon\Carbon::parse($customer->date_of_birth)->format('m-d-Y'), // Format the date 'state_xid' => $customer->state->name ?? '', // Access the state name and handle null 'phone_number' => $customer->phone_number, ]; @@ -61,7 +61,7 @@ class customer_export_selected implements FromCollection, WithHeadings 'Last Name', 'Email Address', 'Date of Birth', - 'state_name', + 'State Name', 'Phone Number' ]; } diff --git a/app/Http/Controllers/Admin/ManageCustomerController.php b/app/Http/Controllers/Admin/ManageCustomerController.php index 7a97214..97efa0b 100644 --- a/app/Http/Controllers/Admin/ManageCustomerController.php +++ b/app/Http/Controllers/Admin/ManageCustomerController.php @@ -218,27 +218,12 @@ class ManageCustomerController extends Controller } } - - // public function exportSelectedCustomer(Request $request) - // { - // // dd($request->all()); - - - // try { - // if ($request->has('all_id')) { - // return Excel::download(new customer_export, 'Passport_data.xlsx'); - // } - - // $ids = $request->selected_id; - // // dd( $ids); - // $fileName = 'selected_customer_data.xlsx'; - // return Excel::download(new customer_export_selected($ids), $fileName); - // // dd($ids); - // } catch (\Exception $e) { - // return response()->json(['error' => 'Export failed. Something went wrong.'], 500); - // } - // } - + /* + Created By : Sayali Parab + Created at : 28 May 2024 + Use : To Get Excel. + */ + public function exportSelectedCustomer(Request $request) { try { diff --git a/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php b/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php index ed06943..4e94c34 100644 --- a/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php +++ b/resources/views/Admin/pages/manage_users/manage_customer/customer.blade.php @@ -115,7 +115,7 @@ $currentPage = 'manage-customer'; View - {{ \Carbon\Carbon::parse($customer->date_of_birth)->format('d/m/Y') }} + {{ \Carbon\Carbon::parse($customer->date_of_birth)->format('m/d/Y') }} {{ $customer->phone_number }} {{ $customer->state ? $customer->state->name : 'No state assigned' }}