SQLSTATE [42P01]:未定义表:7错误:存在的关系

时间:2019-03-16 20:26:28

标签: laravel migration

这是迁移:

class CreateRevdepensesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('revdepenses', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('libelle');
            $table->string('type');
            $table->decimal('montant', 10, 2);
            $table->string('description')->nullable();
            $table->date('date');
            $table->string('payement');
            $table->timestamps();
        });
    }

我在途中写道:

Route::resource('revenu','RevenusController');

在RevenusController方法索引中:

 public function index()
    {
        $rev = RevDep::all();
        return view('revenu', compact('rev'));
    }

我的模态:

class RevDep extends Model
{
    protected $fillable=['id','libelle','type','montant','description','date','payement'];
}

这是我的观点revenu.blade.php(我只是在打招呼)

@extends('index')
@section('content')
<h1>hello</h1>
@endsection

I got this error, the table "rev_deps" doesn't exist, in fact i don't have this table because i dropped it and i re-create a migration named "revdepenses"

ps:我尝试使用php artisan migration:刷新和刷新,但仍然无法正常工作

1 个答案:

答案 0 :(得分:0)

在模型类中,您将不得不提及表的名称,因为表名称未遵循约定。所以

class RevDep extends Model
{
    protected $table = "revdepenses";
    protected $fillable=['id','libelle','type','montant','description','date','payement'];
}