diff --git a/src/AuthRouteMethods.php b/src/AuthRouteMethods.php index 3faa6b5..0b58f13 100644 --- a/src/AuthRouteMethods.php +++ b/src/AuthRouteMethods.php @@ -13,38 +13,42 @@ class AuthRouteMethods public function auth() { return function ($options = []) { - // Login Routes... - if ($options['login'] ?? true) { - $this->get('login', 'Auth\LoginController@showLoginForm')->name('login'); - $this->post('login', 'Auth\LoginController@login'); - } - - // Logout Routes... - if ($options['logout'] ?? true) { - $this->post('logout', 'Auth\LoginController@logout')->name('logout'); - } + $namespace = class_exists($this->prependGroupNamespace('Auth\LoginController')) ? null : 'App\Http\Controllers'; - // Registration Routes... - if ($options['register'] ?? true) { - $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register'); - $this->post('register', 'Auth\RegisterController@register'); - } + $this->group(['namespace' => $namespace], function() use($options) { + // Login Routes... + if ($options['login'] ?? true) { + $this->get('login', 'Auth\LoginController@showLoginForm')->name('login'); + $this->post('login', 'Auth\LoginController@login'); + } - // Password Reset Routes... - if ($options['reset'] ?? true) { - $this->resetPassword(); - } + // Logout Routes... + if ($options['logout'] ?? true) { + $this->post('logout', 'Auth\LoginController@logout')->name('logout'); + } - // Password Confirmation Routes... - if ($options['confirm'] ?? - class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) { - $this->confirmPassword(); - } + // Registration Routes... + if ($options['register'] ?? true) { + $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register'); + $this->post('register', 'Auth\RegisterController@register'); + } - // Email Verification Routes... - if ($options['verify'] ?? false) { - $this->emailVerification(); - } + // Password Reset Routes... + if ($options['reset'] ?? true) { + $this->resetPassword(); + } + + // Password Confirmation Routes... + if ($options['confirm'] ?? + class_exists($this->prependGroupNamespace('Auth\ConfirmPasswordController'))) { + $this->confirmPassword(); + } + + // Email Verification Routes... + if ($options['verify'] ?? false) { + $this->emailVerification(); + } + }); }; }