![](/img/trans.png)
[英]SQLSTATE[42S02]: Base table or view not found: 1146 Table X doesn't exist
[英]SQLSTATE[42S02]: Base table or view not found: 1146 Table '***.indices' doesn't exist laravel
我有表 indexpage 但仍然有这个错误! 这是我的代码:
public function up()
{
Schema::create('index', function (Blueprint $table) {
$table->increments('id');
$table->text('about');
$table->string('video');
$table->timestamps();
});
}
模型:
class Index extends Model
{
protected $fillable = [
'about' ,'video'
];
}
指数从何而来?
按照惯例,除非明确指定另一个名称,否则将使用类的复数名称“snake case”作为表名。
在您的索引模型中,您需要明确指定表名
class Index extends Models {
protected $table = 'index';
...
}
indices
是“指数”的复数形式。 默认情况下,laravel 会查找模型的复数形式。例如App\\User
指的是users
表。 这就是约定。
未找到'***.indices'
,但您的架构类(迁移)正在创建“索引”表。
在您的模型中添加以下内容。 应该工作正常。
protected $table = 'index';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.