Laravel assumes the database table is the plural form of the model name

前端 未结 4 1471
南笙
南笙 2021-01-11 14:09

By default, Laravel is assuming that the database table is the plural form of the model name. But what if my table name is \"news\" and i still want to use this feature? sho

4条回答
  •  北海茫月
    2021-01-11 14:53

    Inside your eloquent model you have to define table name. For example if my model is named user and table in database is named user_of_application then i do it this way

    class user extends Model
    {
        protected $table = 'user_of_application';
    }
    

提交回复
热议问题