Я пытался использовать несколько аутентификаций в laravel 5.7. Все началось нормально, и я могу зарегистрироваться у пользователя, используя аутентифицированные модели, созданные laravel, код ошибки:
Аргумент 1 передан Illuminate \ Auth \ SessionGuard :: login () must
реализовать интерфейс Illuminate \ Contracts \ Auth \ Authenticatable, null
дано, называется
C: \ XAMPP-7.3.5 \ HTDOCS \ jatimsakti \ поставщика \ Laravel \ Framework \ SRC \ Осветите \ Foundation \ Auth \ RegistersUsers.php
по линии 35 ◀
/**
* Log a user into the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @return void
*/
public function login(AuthenticatableContract $user, $remember = false)
{
$this->updateSession($user->getAuthIdentifier());
// If the user should be permanently "remembered" by the application we will
// queue a permanent cookie that contains the encrypted copy of the user
// identifier. We will then decrypt this later to retrieve the users.
if ($remember) {
$this->ensureRememberTokenIsSet($user);
$this->queueRecallerCookie($user);
}
// If we have an event dispatcher instance set we will fire an event so that
// any listeners will hook into the aut
Я пытался установить контроллеры входа, но я никогда не прикасался ни к одной из моделей аутентификации из laravel
мой клинок для регистрации был
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
@csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="unit" class="col-md-4 col-form-label text-md-right">{{ __('Unit') }}</label>
<div class="col-md-6">
<select id="unit" name="unit" class="form-control">
<option value="1">OJK</option>
<option value="2">Humas</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
это мой маршрут
Route::get('/', function () {
return view('home');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
//Fitur Pengajuan Anggaran
Route::get('daftar', 'PegawaiController@showDaftarAnggaran')->name('daftar.anggaran');
Route::get('form', 'PegawaiController@showFormAnggaran')->name('form.anggaran');
Route::POST('form', 'PegawaiController@createFormAnggaran')->name('post.form.anggaran');
Route::post('/form/upload', 'PegawaiController@proses_upload');
Route::get('unit','PegawaiController@showAnggaranUnit')->name('unit.anggaran');
Route::get('daftar/{id}', 'PegawaiController@showDaftarAnggaranUnit')->name('daftar.anggaran.unit');
Вот мой контроллер
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
User::create([
'name' => $data['name'],
'email' => $data['email'],
'id_unit' => $data['unit'],
'password' => Hash::make($data['password']),
]);
}
}
А это была моя модель пользователя
<?php
/**
* Created by Reliese Model.
* Date: Sat, 01 Jun 2019 15:27:42 +0000.
*/
namespace App\Models;
use Reliese\Database\Eloquent\Model as Eloquent;
/**
* Class User
*
* @property int $id
* @property int $id_unit
* @property string $name
* @property string $email
* @property \Carbon\Carbon $email_verified_at
* @property string $password
* @property string $remember_token
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
*
* @property \App\Models\Unit $unit
*
* @package App\Models
*/
class User extends Eloquent
{
protected $casts = [
'id_unit' => 'int'
];
protected $dates = [
'email_verified_at'
];
protected $hidden = [
'password',
'remember_token'
];
protected $fillable = [
'name',
'email',
'id_unit',
'email_verified_at',
'password',
'remember_token'
];
public function unit()
{
return $this->belongsTo(\App\Models\Unit::class, 'id_unit');
}
}
Я ожидал добавить идентификатор устройства в таблицы модулей, это мое единственное настраиваемое поле, данные вводились через php моего администратора, но когда я пытался создать * 1023, произошла ошибка