Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user = User::create([
- 'name' => request('name'),
- 'email' => request('email'),
- 'password' => bcrypt(request('password'))
- ]);
- <form method="POST" action="/login">
- {{ csrf_field() }}
- <div class="form-group">
- <label for="Email">Email:</label>
- <input type="email" class="form-control" id="Email" name="Email" required>
- </div>
- <div class="form-group">
- <label for="password">Password:</label>
- <input type="password" class="form-control" id="password" name="password" required>
- </div>
- <div class="form-group">
- <button type="submit" class="btn btn-primary">Sign in</button>
- </div>
- @include ('layouts.errors')
- </form>
- Route::get('/login', 'SessionsController@create')->name('login');
- Route::post('/login', 'SessionsController@store');
- Route::get('/logout', 'SessionsController@destroy');
- <?php
- class SessionsController extends Controller
- {
- public function __construct()
- {
- $this->middleware('guest');
- }
- public function create()
- {
- return view('sessions.create');
- }
- public function store()
- {
- // Attempt to authenticate the user.
- if (! auth()->attempt(request(['email', 'password']))) {
- return back();
- }
- // Redirect them to the homepage
- return redirect()->home();
- }
- public function destroy()
- {
- auth()->logout();
- return redirect()->home();
- }
- }
- <div class="form-group">
- <div class="alert alert-errors">
- <ul>
- @foreach($errors->all() as $error)
- <li> {{ $error }} </li>
- @endforeach
- </ul>
- </div>
- </div>
Add Comment
Please, Sign In to add comment