search

Home  >  Q&A  >  body text

php - How are the model I created using artisan and the migrate data table bound together in Laravel?

Suppose I first create a table of questions using migrate;

Then I used artisan to create a model of Question;

There is no statement in the model that binds the data table. Why does the framework automatically search for my questions table when I write a method, and make corresponding additions, deletions, and modifications? Don’t you need to bind the table first?

怪我咯怪我咯2813 days ago422

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-16 13:02:45

    Code location: IlluminateDatabaseEloquentModel.php

    如果没有显式地定义protected $table='xxxx';The class name of the current Model will be used as the table name. This is not only laravel, many other PHP frameworks do this

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:02:45

    Correct answer upstairs...

    reply
    0
  • Cancelreply