Reputation: 533
I am trying to move all my routes inside a subdomain routes group. When I put routes inside subdomain group, issues arise. Routes become undefined. This way works.
Route::group(['middleware' => 'auth'], function () {
Route::get('dashboard', 'HomeController@dashboard')->name('dashboard');
Route::get('profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);
Route::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);
});
This way does not work. Links generated with route helper generates undefined errror, href="{{ route('profile.edit') }}"
Route::group(['middleware' => 'auth'], function () {
Route::domain('{username}.'.env('SESSION_DOMAIN'))->group(function () {
Route::get('dashboard', 'HomeController@dashboard')->name('dashboard');
Route::get('profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);
Route::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);
});
});
I thought I came up with a solution when I used url helper, href="{{ url('profile.edit') }}"
, but a new problem started. Links to other pages were fine, but form submission actions generated a error
Missing required parameters
What am I doing wrong?
Upvotes: 0
Views: 576
Reputation: 6233
your route requires the subdomain parameter. {username}
needs to be passed with your route but you are not passing anything. thus the missing required parameters error comes. you have to call a route like
href="{{ route('profile.edit', 'subdomain_name') }}"
or if you have a fixed subdomain then just remove {username}
from your route definition and use the exact sub domain.
Route::group(['middleware' => 'auth'], function () {
Route::domain('subdomain_name.'.env('SESSION_DOMAIN'))->group(function () {
Route::get('dashboard', 'HomeController@dashboard')->name('dashboard');
Route::get('profile', ['as' => 'profile.edit', 'uses' => 'ProfileController@edit']);
Route::put('profile', ['as' => 'profile.update', 'uses' => 'ProfileController@update']);
});
});
Upvotes: 1