middleware('auth', ['except' => ['index', 'show']]); } public function index() { $customer_logs = CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->orderByDesc('updated_at')->paginate(); return view('customer_logs.index', compact('customer_logs')); } public function show($customer_log_id) { $customer_log =CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$customer_log_id)->first(); return view('customer_logs.show', compact('customer_log')); } public function create(CustomerLog $customer_log) { $customers = Customer::all(); $customerLogStatuses = CustomerLogStatus::all(); return view('customer_logs.create_and_edit', compact('customer_log', 'customers', 'customerLogStatuses')); } public function store(Request $request): RedirectResponse { $data = []; $data = $request->all(); $data['user_id'] = auth()->id(); $customer_log = CustomerLog::create($data); return redirect()->route('customer_logs.show', $customer_log->id)->with('message', 'Created successfully.'); } public function edit(CustomerLog $customer_log) { $this->authorize('update', $customer_log); $customers = Customer::all(); $customerLogStatuses = CustomerLogStatus::all(); return view('customer_logs.create_and_edit', compact('customer_log', 'customers', 'customerLogStatuses')); } public function update(Request $request, CustomerLog $customer_log) { $this->authorize('update', $customer_log); $customer_log->update($request->all()); return redirect()->route('customer_logs.show', $customer_log->id)->with('message', 'Updated successfully.'); } public function destroy(CustomerLog $customer_log) { $this->authorize('destroy', $customer_log); $customer_log->delete(); return redirect()->route('customer_logs.index')->with('message', 'Deleted successfully.'); } }