我正在尝试为我的 Laravel 项目制作一个登录页面,注册不是问题,但是当我尝试登录时它给了我一个数据库不存在的错误,有趣的是,数据库确实存在,因为我使用它在我的主页上。
但是当我尝试在登录页面上登录时,它说:'[2023-02-28 17:48:11] local.ERROR: SQLSTATE[HY000] [1049] Unknown database 'laravel''
这是我的 web.php
<?php
use App\Http\Controllers\ArtistViewController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/inschrijven', function () {
return view('inschrijven');
});
Route::get('/',[ArtistViewController::class, 'Index']);
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
这是用户模型。
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'username',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
我尝试了多种方法,通过创建一个新数据库,将所有内容迁移到它。什么都不起作用。
有人可以帮帮我吗?
亲切的问候,
托尼
我尝试了一切,通过删除数据库,创建了一个新数据库。我在 AuthenticatesUsers.php 的登录函数中执行了 dd(),它在第一行转储。