Здравствуйте. Я пытаюсь войти в систему с правами администратора, и после выполнения всего, что я знаю, во время входа в систему я получаю сообщение об ошибке «Учетные данные не соответствуют нашим записям». Вот мой код. auth. php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\admin::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
logincontroller
<?php
namespace App\Http\Controllers\Admin\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/admin/dashboard';
public function showLoginForm()
{
return view('admin.login');
}
public function login(Request $request)
{
$this->validateLogin($request);
if ($this->attemptLogin($request)){
return $this->sendLoginResponse($request);
}
return $this->sendFailedLoginResponse($request);
}
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function guard()
{
return Auth::guard('admin');
}
}
admin. php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class admin extends Authenticatable
{
use Notifiable;
protected $guard = 'admin';
protected $primaryKey = 'admin_id';
protected $fillable = [
'name','email','password',
];
protected $table = 'admin';
}
login.blade
@if(count($errors)>0)
<div class="alert alert-success" role="alert">
<ul>
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
<form class="form-horizontal" action="{{route('admin.login')}}" method="post">
{{csrf_field()}}
<fieldset>
<div class="form-group">
<label for="email" class="col-lg-4 control-label">Email</label>
<div class="col-lg-8">
<input type="email" class="form-control" id="email" name="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-4 control-label">Password</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="inputPassword" name="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="submit" class="btn btn-primary btn-block">LOGIN</button>
</div>
</div>
</fieldset>
</form>'''
web.php
Route::get('admin','Admin\Auth\LoginController@showLoginForm')->name('admin.login');
Route::post('admin','Admin\Auth\LoginController@login');