initial commit
This commit is contained in:
67
app/Http/Controllers/Doctor/Auth/LoginController.php
Normal file
67
app/Http/Controllers/Doctor/Auth/LoginController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\doctor\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Doctor;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/doctor';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
public function showLoginForm()
|
||||
{
|
||||
return view('doctor.auth.login');
|
||||
}
|
||||
|
||||
protected function login(Request $request)
|
||||
{
|
||||
$credentials = $request->only('email', 'password');
|
||||
|
||||
$user = Doctor::where($this->username(), $credentials['email'])->first();
|
||||
|
||||
if ($user && Hash::check($credentials['password'], $user->password)) {
|
||||
Auth::guard('doctor')->login($user, $request->has('remember'));
|
||||
return redirect($this->redirectTo);
|
||||
}
|
||||
|
||||
return back()->withErrors(['email' => 'Invalid credentials']);
|
||||
}
|
||||
|
||||
public function redirectPath() {
|
||||
return "/doctor";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user