Guest User

Untitled

a guest
Oct 10th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. $user = User::create([
  2. 'name' => request('name'),
  3. 'email' => request('email'),
  4. 'password' => bcrypt(request('password'))
  5. ]);
  6.  
  7. <form method="POST" action="/login">
  8.  
  9. {{ csrf_field() }}
  10.  
  11. <div class="form-group">
  12.  
  13. <label for="Email">Email:</label>
  14.  
  15. <input type="email" class="form-control" id="Email" name="Email" required>
  16.  
  17. </div>
  18.  
  19. <div class="form-group">
  20.  
  21. <label for="password">Password:</label>
  22.  
  23. <input type="password" class="form-control" id="password" name="password" required>
  24.  
  25. </div>
  26.  
  27. <div class="form-group">
  28.  
  29. <button type="submit" class="btn btn-primary">Sign in</button>
  30.  
  31. </div>
  32.  
  33. @include ('layouts.errors')
  34.  
  35. </form>
  36.  
  37. Route::get('/login', 'SessionsController@create')->name('login');
  38. Route::post('/login', 'SessionsController@store');
  39. Route::get('/logout', 'SessionsController@destroy');
  40.  
  41. <?php
  42.  
  43.  
  44. class SessionsController extends Controller
  45. {
  46. public function __construct()
  47.  
  48. {
  49.  
  50. $this->middleware('guest');
  51.  
  52. }
  53.  
  54. public function create()
  55.  
  56. {
  57.  
  58. return view('sessions.create');
  59.  
  60. }
  61.  
  62. public function store()
  63.  
  64. {
  65.  
  66. // Attempt to authenticate the user.
  67.  
  68. if (! auth()->attempt(request(['email', 'password']))) {
  69.  
  70. return back();
  71.  
  72. }
  73.  
  74. // Redirect them to the homepage
  75.  
  76. return redirect()->home();
  77. }
  78.  
  79. public function destroy()
  80.  
  81. {
  82.  
  83. auth()->logout();
  84.  
  85.  
  86. return redirect()->home();
  87.  
  88. }
  89. }
  90.  
  91. <div class="form-group">
  92.  
  93. <div class="alert alert-errors">
  94.  
  95. <ul>
  96.  
  97. @foreach($errors->all() as $error)
  98.  
  99. <li> {{ $error }} </li>
  100.  
  101. @endforeach
  102.  
  103. </ul>
  104.  
  105. </div>
  106.  
  107. </div>
Add Comment
Please, Sign In to add comment