Skip to content
Advertisement

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘***.indices’ doesn’t exist laravel

I have table indexpage but still have this error! this is my code:

   public function up()
    {
        Schema::create('index', function (Blueprint $table) {
            $table->increments('id');
            $table->text('about');
            $table->string('video');
            $table->timestamps();
        });
    }

model:

class Index extends Model
{
    protected $fillable = [
        'about' ,'video'
    ];
}

where indices come from?

Advertisement

Answer

By convention, the “snake case”, plural name of the class will be used as the table name unless another name is explicitly specified.

In your Index Model, you need to explicitly specified the table name

class Index extends Models {
    protected $table = 'index';
    ...
}
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement