with('customers', Customer::select(['id', 'location']) ->with('user:id,name,email,role_id,role_type') ->get() ); } public function edit(Customer $customer) { return view('dashboards.admin.customers.edit') ->with('profile', $customer->user) ->with('backLink', route('admin.customers.index')) ->with('actionLink', route('admin.customers.update', $customer)); } public function update(StoreCustomerProfileRequest $request, Customer $customer, UpdateCustomerAction $action) { try { $action->execute($request->validated(), $customer->user); return to_route('admin.customers.index') ->with('success', 'Profile updated successfully.'); } catch (\Throwable $e) { Log::error('Customer Profile Update Failed: '.$e->getMessage(), $e->getTrace()); return back()->withInput()->with('error', 'Something went wrong.'); } } public function destroy(Customer $customer) { try { \DB::transaction(function () use ($customer) { $customer->user->delete(); $customer->delete(); }); return back()->with('success', 'Customer deleted successfully.'); } catch (\Throwable $e) { Log::error('Customer Delete Failed: '.$e->getMessage(), $e->getTrace()); return back()->with('error', 'Something went wrong.'); } } }