我试图为我的Laravel项目做一个登录页面,注册不是问题,但当我尝试登录它给了我一个错误,数据库不exist,有趣的事情,数据库不exist,因为我用它在我的主页。
但当我试图登录到登录页面,它说:'[2023 - 02 - 28 17:48:11]本地。错误:SQLSTATE [HY000][1049]未知数据库'laravel''
在. env中是否所有内容都正确
这是我的博客
<?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',
];
}
我尝试了很多方法,比如创建一个新的数据库,把所有的数据都迁移到它上面,但是没有任何效果。
有人能帮帮我吗?
此致,
东尼
我尝试了所有的方法,通过删除数据库,创建了一个新的数据库。我在authenticatesusersiderphp的登录函数中做了dd(),它在第一行转储。
这是数据库
在尝试了多种方法后,并使用数据库连接测试数据库名称'laravel',is说:
PS C:\xampp\htdocs\app> php artisan serve
"Database is connected. Database Name is : laravel" //
app\Providers\AppServiceProvider.php:24
INFO Server running on [http://127.0.0.1:8000].
Press Ctrl+C to stop the server
1条答案
按热度按时间ldxq2e6h1#
我修复了它,我想我的文件损坏了。所以它不起作用,我做了一个新的项目,它工作得很好!
谢谢你和我一起思考:)