gpt4 book ai didi

laravel - 找不到基表或 View : 1146 Table

转载 作者:行者123 更新时间:2023-12-01 22:06:03 25 4
gpt4 key购买 nike

错误:

Illuminate \ Database \ QueryException (42S02) SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mmictltd.admins' doesn't exist (SQL: select * from admins where email = kayondoronald2015@gmail.com limit 1)

我的create_admin_table.php

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('admin', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('admin');
}
}

Laravel error illustration

最佳答案

您的表在迁移中称为“admin”,但在查询中您正在寻找“admins”。

您可以通过 $table 在您的模型中指定表名:

/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'admin';

Laravel 约定在这种情况下表名应该是复数:https://laravel.com/docs/5.6/eloquent

因此我建议您将迁移从“admin”更改为“admins”。

关于laravel - 找不到基表或 View : 1146 Table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51966767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com