I have a Laravel website with a table 'users' that stores the role_id, and a table 'companies' that stores custom permalinks. The default login routes are used for the users with the ADMIN role. I need to add other views and routes for the users with the CLIENT role. So, when a user accesses the URL '/custom-company-permalink-from-db' and he is not logged in, he should be redirected to the URL '/custom-company-permalink-from-db/login'.
Here are my routes:
Route::middleware('web')->group(function() {
Auth::routes(['register' => false]);
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'home']);
Route::get('/{company}', ['uses' => 'HomeController@overview', 'as' => 'overview']);
});
Route::namespace('Admin')->prefix('admin')->name('admin.')->middleware(['auth', 'check.if.admin'])->group(function() {
Route::get('/dashboard', ['as' => 'dashboard', 'uses' => 'AdminController@dashboard']);
});
I am thinking about adding this to the routes:
Route::get('/{company?}/login','Frontend\Auth\LoginController@showLoginForm')->name('client.login');
And then copying the app/Http/Controllers/Auth files to app/Http/Controllers/Frontend/Auth and making the necessary edits.
Is there another way of achieving this? What's the recommended way?