12345678910111213141516171819202122232425262728293031323334 |
- <?php
-
- namespace App\Http\Controllers;
-
- use App\Models\User;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Hash;
-
- class AdminController extends Controller
- {
- public function showLoginForm()
- {
- return view('admin.login');
- }
-
- public function login(Request $request)
- {
- $credentials = $request->only('email', 'password');
- $user = User::where('email', $credentials['email'])->first();
- if (!$user || !Hash::check($credentials['password'], $user->password)) {
- return back()->withErrors([
- 'email' => 'The provided credentials do not match our records.',
- ]);
- }else{
- auth()->login($user);
- return redirect()->intended('admin/dashboard');
- }
- }
-
- public function dashboard()
- {
- return view('admin.dashboard');
- }
- }
|