Redirect to a specific domain specified route

- 1 answer

Ad

Consider the following route set up:

Route::group(['domain' => 'blog.adambalan.local'], function() {
    Route::get('login', '[email protected]');
    Route::get('blogs', '[email protected]');
    Route::post('postLogin', '[email protected]');
});

Now consider the following, which is in the postLogin:

    if (Auth::attempt($credentials)) {
        Session::flash('success', "Welcome back Adam. Care to manage your blogs?");
        return redirect()->route('blogs');
    } else {
        return redirect()->back()->withErrors(['We could not log you in. Sorry.']);
    }

The issue is with: return redirect()->route('blogs');

The error is: Route [blogs] not defined.Is there a specific thing I'm suppose to do? A specific way to call domain specific routes?

Ad

Answer

Ad

You would need to name a route 'blogs'. The redirect()->route('blogs') refers to a route name not a url/path.

For a url/path you can use redirect()->to($url) or just redirect($url).

Laravel - Routing - Named Routes

Ad
source: stackoverflow.com
Ad