I have a Laravel application with following routes:
- http://site-name/ (auth)
- http://site-name/home (public)
- http://site-name/about (public)
As http://site-name/ needs authorized user, it needs a login check. I have written a following route for this
Route::get('/', 'SiteController@index');
Where SiteController is,
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SiteController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('play');
}
}
Above __construct()
will redirect the user to http://site-name/login view.
Now, the tricky part starts. I need to modify my laravel application such that, for login, it would show the login view to unauthorized user on http://site-name/ instead of redirecting to http://site-name/login for login.