Advertisement
ichigogeta

vistaController.php

Feb 16th, 2022
715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Auth;
  7.  
  8.  
  9. class vistaFormulario extends Controller
  10. {
  11.     //SI USAMOS EN RETURN "REQUEST()" Nos saldrá un json con los datos introducidos del formulario.
  12.     public function verLogin(Request $datos){
  13.         $datosFormulario = request()->only('email','password');
  14.         //dump() y @dd() o dd() sirven para lo mismo, lanzan el error o la info del formulario en array json;
  15.         //return ;
  16.        
  17.         if(Auth::attempt($datosFormulario)){
  18.            
  19.             request()->session()->regenerate();
  20.             return redirect()->route('vistaDasboard');
  21.         }else{
  22.             return redirect()->route('vistaLogin');
  23.         }
  24.        
  25.     }
  26.  
  27.     public function vistaWelcome(){
  28.         //DEL CAMPO OCULTO CONSULTARIAMOS EN LA BD EL EMAIL Y EL PASSWORD. SI SON IGUALES, DESCONECTAMOS. PARA LA SEGURIDAD.
  29.         return view('welcome');
  30.        
  31.     }
  32.  
  33.     public function vistaLogin(){
  34.         return view('login');
  35.     }
  36.  
  37.    
  38.     public function vistaDashboard(){
  39.         return view('dashboard');
  40.     }
  41.    
  42.  
  43.     public function desconectar(){
  44.         Auth::logout();
  45.         return redirect()->route('vistaWelcome');
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement