user()) { return redirect()->intended('cust.dashboard'); } return view('customer.auth.login'); } public function authenticate(Request $request) { $credentials = $request->only('username', 'password'); if (Auth::guard('customer')->attempt($credentials, $request->get('remember-me'))) { $request->session()->regenerate(); return redirect()->intended('cust.dashboard'); } return redirect()->back()->with('error', 'Data kredensial tidak dapat diterima.'); } public function register() { return view('customer.auth.register'); } public function store(Request $request) { // Validate the request data $request->validate([ 'name' => 'required|string|max:255', 'username' => 'required|string|max:255|unique:auth_customers', 'email' => 'required|string|email|max:255|unique:auth_customers', 'password' => 'required|string|min:8|confirmed', 'customer_type' => 'required|in:individual,company', 'nib' => 'nullable|string|max:255', 'npwp' => 'nullable|string|max:255', 'address' => 'nullable|string|max:255', 'phone_no' => 'nullable|string|max:20', 'pic' => 'nullable|string|max:255', ]); // Create the customer $customer = new \App\Models\Customer($request->all()); $customer->password = bcrypt($request->password); $customer->save(); // Redirect or return response return redirect()->route('website.register.success'); } }