当我想打开管理员身份验证系统页面时,它会收到以下错误。另外,我正在使用 localhost XAMPP 服务器。收到的第一个错误:已用完允许的 536870912 字节的内存大小。现在我找到了解决方案,所以我增加了 php.ini 文件的内存大小限制。
然后第二个收到错误:超过了 60 秒的最大执行时间。现在我找到了解决方案,因此我增加了 php.ini 文件的最大执行时间。
然后页面无法打开,因为该页面无法处理请求。有没有人有解决方案?
路线:
Auth::routes();
Route::middleware('auth')->group(function (){
Route::get('/dashboard',function (){
return view('dashboard');
});
Route::get('/faculty', function (){
$title='Faculty Console';
return view('faculty-dashboard',compact('title'));
});
Route::get('/student', function (){
$title='Student Console';
return view('user-dashboard',compact('title'));
});
Route::prefix('admin')->group(function () {
Route::get('/', function (){
$student=User::all()->where('user_role','student')->count();
$employee=User::all()->where('user_role','employee')->count();
$title='Admin Console';
return view('admin.admin-dashboard',compact('title','student','employee'));
});
Route::resource('selection','SelectionController');
Route::get('selection/{id}/pivot-create/','SelectionController@pivotCreate')->name('pivotCreate');
Route::get('selection/{id}/pivot-destroy/','SelectionController@pivotDestroy')->name('pivotDestroy');
});
});
验证码
'defaults' => [
//'guard' => 'web',
'guard' => 'user',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'user' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
'password_timeout' => 10800,
应用程序/用户.php
class User extends Authenticatable
{
use Notifiable;
protected $guarded = [];
protected $table='users';
protected $hidden = ['password', 'remember_token',];
protected $casts = [
'email_verified_at' => 'datetime',
];
protected $dates = ['created_at', 'updated_at'];
}
登录控制器
class LoginController extends Controller
{
use AuthenticatesUsers;
public function username()
{
return 'user_name';
}
protected function redirectTo(){
if (Auth::user()->user_role == 'admin' && Auth::user()->status == '1'){
//alert()->message('Welcome','Admin')->closeOnClickOutside();
return '/admin';
}
elseif (Auth::user()->user_role == 'faculty' && Auth::user()->status == '1'){
//alert()->message('Welcome','Faculty')->closeOnClickOutside();
return '/faculty';
}
elseif (Auth::user()->user_role == 'student' && Auth::user()->status == '1'){
//alert()->message('Welcome','Student')->closeOnClickOutside();
return '/student';
}
else
return redirect('/login');
}
public function logout()
{
Auth::logout();
//session()->flash('msg_logout', 'Panel System Successfully Logout');
alert()->success('You have been logout successfully','GoodBye');
//session()->flush();
return redirect('/login');
}
public function showLoginForm(){
$title='TheMSC-Sign-In Panel-System';
return view('log-in',compact('title'));
}
}
注册控制器
class RegisterController extends Controller
{
use RegistersUsers ;
protected $redirectTo = RouteServiceProvider::HOME;
protected function validator(array $data)
{
return Validator::make($data, [
'cnic' => ['required','string'],
'user_name'=>[ 'required','string','unique:users','regex:[a-z\d-]'],
'user_role'=>[ 'required','string'],
'email' => [ 'required', 'string', 'email:filter,dns'],
'password' => [ 'required', 'string', 'confirmed','regex:[a-zA-Z\d $&+,:;=?@#|\'<>.^*()%!-]'],
]);
}
protected function create(array $data)
{
return User::create([
'cnic' => $data['cnic'],
'user_name' => $data['user_name'],
'user_role' => $data['user_role'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}