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?
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 thisCorrect answer upstairs...