I need to protect them from viewing. That means without logging in it should not redirect to any other pages, if anyone tries to access, it should get back to login page.
I am using Laravel 5.4 and regular authentication
php artisan make:auth
And in login controller
protected $redirectTo = '/home';
And in Middleware RedirectifAuthenticated I am trying like this but it is not working.
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
return redirect('/leadsadd');
return redirect('/leadslist');
return redirect('/opporadd');
return redirect('/opporlist');
return redirect('/accadd');
return redirect('/acclist');
return redirect('/selftask');
}
return $next($request);
}
It's not working. I think the method I am doing is wrong. Can any one help how can I prevent it and should not redirect to any route or URL. Route
Route::get('/', function () {
return view('auth.login');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::get('leadsadd','crmcontroller@addleads');
Route::get('leadslist', 'crmcontroller@leadslist');
Route::any('leadview/{id}','crmcontroller@show');
Route::get('leadedit/{id}','crmcontroller@edit');
Thanks in advance.