123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- class SessionsController extends Controller
- {
- public function __construct()
- {
- $this->middleware('guest')->only('store');
- }
- public function create()
- {
- return view('sessions.create');
- }
- public function destroy() {
- auth()->logout();
- return redirect()->home();
- }
- public function store()
- {
- // Attempt to authenticate the user.
- // On failure, redirect back.
- if (!auth()->attempt(request(['email', 'password']))) {
- return back()->withErrors([
- 'message' => 'Please check your credentials and try again',
- ]);
- };
- // On success, sign them in.
- // Then redirect to home.
- return redirect()->home();
- }
- }
|