模型和表命名约定 Laravel [英] Model and table name conventions Laravel

查看:30
本文介绍了模型和表命名约定 Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解 Laravel 中的模型和表格约定.

I want to know model and table conventions in Laravel.

我现在有表 users 和 user_address 我不想使用

I have table users and user_address now I do not want to use

protected $table = "user_address"

protected $table = "user_address"

财产.请建议我在模型或表格中使用正确的约定.

property. Please suggest me the right convention in model or table.

推荐答案

如果模型的名字是UserAddress,表的名字应该是复数.所以它将是 user_addresses.

If the name of the model is UserAddress, the name of the table should be plural. So it will be user_addresses.

此处阅读有关 Laravel 命名约定的更多信息.

Read more about Laravel naming conventions here.

这篇关于模型和表命名约定 Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆