Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppHttpControllersAuth;
- use AppHttpControllersController;
- use IlluminateFoundationAuthAuthenticatesUsers;
- class LoginController extends Controller
- {
- /*
- |--------------------------------------------------------------------------
- | Login Controller
- |--------------------------------------------------------------------------
- |
- | This controller handles authenticating users for the application and
- | redirecting them to your home screen. The controller uses a trait
- | to conveniently provide its functionality to your applications.
- |
- */
- use AuthenticatesUsers;
- /**
- * Where to redirect users after login.
- *
- * @var string
- */
- protected $redirectTo = '/';
- /**
- * Create a new controller instance.
- *
- * @return void
- */
- public function __construct()
- {
- $this->middleware('guest', ['except' => 'logout']);
- // $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
- }
- // public function getLogout()
- // {
- // return $this->logout();
- // }
- public function logout()
- {
- Auth::guard($this->getGuard())->logout();
- return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
- }
- <?php
- /*
- |--------------------------------------------------------------------------
- | Web Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register web routes for your application. These
- | routes are loaded by the RouteServiceProvider within a group which
- | contains the "web" middleware group. Now create something great!
- |
- */
- // Route::get('test', function(){
- // $user = new AppUser;
- // $user->name = 'luz';
- // $user->email = 'luz@gmail.com';
- // $user->password = bcrypt('123');
- // $user->save();
- // return $user;
- // });
- Route::get('/', ['as' => 'home', 'uses' => 'PagesController@home']);
- Route::get('contactame', ['as' => 'contactos', 'uses' => 'PagesController@contacto']);
- Route::post('contacto', 'PagesController@mensajes');
- // Route::get('saludos/{nombre?}', ['as' => 'Saludos', 'uses' => 'PagesController@saludo'])->where($nombre, "[A-Za-z]+");
- // login - logout
- Route::get('login', 'AuthLoginController@showLoginForm');
- Route::post('login', 'AuthLoginController@login');
- Route::get('logout', 'AuthLoginController@logout');
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- </head>
- <style>
- .active{
- text-decoration: none;
- color: green;
- }
- </style>
- <body>
- <header>
- <?php
- function activeMenu($url){
- return request()->is($url) ? 'active' : '';
- }
- ?>
- <nav>
- <a class="{{ activeMenu('/') }}" href="{{ route('home') }}">Inicio</a>
- <a class="{{ activeMenu('contactame') }}" href="{{ route('contactos') }}">Contactos</a>
- <a href="/logout">Cerrar Sesión de {{ auth()->user()->name }}</a>
- <a class="{{ activeMenu('login') }}" href="/login">Login</a>
- </nav>
- </header>
- @yield('contenido')
- <footer>
- Copyright {{ date('Y') }}
- </footer>
- </body>
- </html>
- @extends('layout')
- @section('contenido')
- <h1>Login</h1>
- <form method="POST" action="/login">
- {!! csrf_field() !!}
- <input type="email" name="email" placeholder="Email">
- <input type="password" name="password" placeholder="Password">
- <input type="submit" value="Entrar">
- </form>
- @stop
- @extends('layout')
- @section('contenido')
- <h1>Home</h1>
- @stop
Add Comment
Please, Sign In to add comment