这是迁移:
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
ps:我尝试使用php artisan migration:刷新和刷新,但仍然无法正常工作
答案 0 :(得分:0)
在模型类中,您将不得不提及表的名称,因为表名称未遵循约定。所以
class RevDep extends Model
{
protected $table = "revdepenses";
protected $fillable=['id','libelle','type','montant','description','date','payement'];
}