0

I can't understand what is happening here. on my local server its working fine but when I put everything on my live server I'm having this error

enter image description here

My web Route

Auth::routes(['verify' => true]); Route::get('/', function(){ return view('auth.login'); })->name('auth.login')->middleware('auth'); Route::resource('/register', 'Auth\registerController@index')->name('register'); Route::group( ['middleware' => 'auth' ], function() { Route::get('/home', 'HomeController@index')->name('home'); Route::group(['namespace' => 'dashboard', 'prefix' => 'dashboard'], function() { Route::get('/', 'DashboardController@index'); }); SO ON... } 

My RegisterController

class RegisterController extends Controller { use RegistersUsers; protected $redirectTo = '/home'; public function __construct() { $this->middleware('guest'); } public function index(Request $request) { $referral = ''; $keyword = $request->get('search'); $referral = Referral::where([ ['code', $keyword], ['status', 0] ])->first(); if (is_null($keyword)) return view ( 'Auth.register'); elseif ($referral) return view ( 'Auth.register', compact('referral', $referral)) ->withDetails ( $referral ) ->withQuery ( $keyword ); else return view ( 'Auth.register')->withMessage ( 'The code you provided is not existing or already been taken.' ); } protected function create(array $data) { $user = User::create([ 'name' => $data['name'], 'country_code' => $data['country_code'], 'phone_number' => $data['phone_number'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); } } 

registerController Path

enter image description here

what do you this causing this?

Thank you in advance!

1
  • 4
    change registerController to RegisterController Commented Jan 5, 2020 at 10:08

3 Answers 3

4

this line of code in your web.php file is causing the issue

Route::resource('/register', 'Auth\registerController@index')->name('register'); 

your class name starts with R but you have written using r. moreover it seems the route is a simple get route but you have written it as resource. change this too. so the route should be like

Route::get('register', 'Auth\RegisterController@index')->name('register'); 
Sign up to request clarification or add additional context in comments.

Comments

0

How did you namespace your registerController?

Because laravel later versions use a rather different namespace than previous versions. Hence change your namespace (and imported files) to this;

namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; 

Comments

0

If you are using laravel 8:

use App\Http\Controllers\Auth\RegisterController; Auth::routes(['register' => false]); Route::get('/user_register', [RegisterController::class, 'showRegistrationForm'])->name('register'); 

However it throws this error when I clean cache:

 Unable to prepare route [user_register] for serialization. Another route has already been assigned name [register]. 

The new route works, but the old route yet it works

1 Comment

changue: ->name('register') to ->name('register2') but the register route is yet visible

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.