2 years ago

How can i set Auth::routes() with a dynamic subdomain

Posted 2 years ago by puffy

I use Laravel 5.4 and i try to develop an app with dynamic subdomain as users.

In routes, web i have

Route::pattern('domain', 'www.localhost.dev|localhost.dev');
Route::group(['domain' => '{domain}'], function()
    Route::get('/', function()
          return view('welcome');

Route::group(['domain' => '{company}.localhost.dev', 'middleware' => 'CheckCompany'], function()
    Route::get('/', function($company)
          return view('welcome', compact('company'));
    Route::get('/home', '[email protected]');

and CheckCompany middleware

namespace App\Http\Middleware;
use App\Company;
use Closure;
use Session;

class CheckCompany
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
    public function handle($request, Closure $next)
        $CompanyUsername = $request->route('company');
        $organisation = Company::where('username', '=', $CompanyUsername)->first();
            Session::put('company', $organisation);
            return $next($request);
        } else {
            return response()->view('errors.nouser', compact('CompanyUsername'));

I need to use /authroutes only if checkcompany is passed. i recive next error on existinguser.localhost.dev/login is accessed

ErrorException in UrlGenerationException.php line 17:
Missing required parameters for [Route: login] [URI: login]. (View: /Users/Web/laravel/devapp/resources/views/auth/login.blade.php)

Please sign in or create an account to participate in this conversation.