Customer::all(), 'tab' => $request->tab, ]); } public function store(CustomerRequest $request) { Customer::create($request->validated()); return redirect()->route('customers.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', [ 'customer' => $customer, 'contacts' => $customer->contacts()->get(), 'packingSlips' => PackingSlip::where('customer_id', $customer->id)->orderByDesc('date_received')->paginate(15), 'tab' => $tab, 'today' => Carbon::today()->format('Y-m-d'), 'shippingEntries' => $customer->shippingEntries()->get(), ]); } 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('customers.index')->with('status', 'Customer deleted successfully.'); } public function destroy(Customer $customer) { $customer->delete(); return redirect()->route('customers.index')->with('status', 'Customer deleted successfully.'); } }