validated()); return redirect()->route('management.index')->with('status', 'Customer created successfully.'); } public function create() { return view('customers.create'); } public function show(Customer $customer, ?string $tab = null) { if (! $tab) { return redirect()->route('customers.show', [$customer, 'tab' => 'details']); } return view('customers.show', [ 'tab' => $tab, 'customer' => $customer, 'contacts' => $customer->contacts()->get(), 'packingSlips' => PackingSlip::where('customer_id', $customer->id)->orderByDesc('date_received')->paginate(15), 'shippingEntries' => $customer->shippingEntries()->get(), 'today' => Carbon::today()->format('Y-m-d'), ]); } public function update(CustomerRequest $request, Customer $customer) { $customer->update($request->validated()); return redirect()->route('customers.show', $customer)->with('status', 'Customer updated successfully.'); } public function requestDestroy(Request $request) { $customer = Customer::find($request->id); $customer->delete(); return redirect()->route('management.index')->with('status', 'Customer deleted successfully.'); } public function destroy(Customer $customer) { $customer->delete(); return redirect()->route('management.index')->with('status', 'Customer deleted successfully.'); } }