How does eloquent recognize tables?

前端 未结 4 1287
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 02:07

I am curious about how eloquent knows in which table it should save the records we give it by running $ php artisan tinker . I do not actually remember setting

4条回答
  •  醉话见心
    2021-01-13 02:39

    Model name is mapped to the plural of table name, like User model maps to users table and so. When you do
    User::all() laravel knows that you want the records from users table.
    To specify the table name explicitly you use protected $table ='name' field on model.

提交回复
热议问题