如何解决Laravel中的唯一表/别名错误?
我对 laravel 非常陌生,我正在使用 l5-repository 包进行 orderBy 和 SortedBy 来对列进行排序,在点击 API 时我收到以下错误,请帮助我解决问题
我的 API URL :-http://localhost.com /v1/domain?limit=250&page=1&orderBy=users|name&sortedBy=desc
I am very new to the laravel,i am using l5-repository package for orderBy and sortedBy to sort columns ,while hitting API i am getting following error please help me to resolve the issue
my API URL :-http://localhost.com/v1/domain?limit=250&page=1&orderBy=users|name&sortedBy=desc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您的表名称中有一个错误。默认情况下,Laravel将寻找
cards
的表名,用于card
的模型。另外,看看您的模型名称。我可以察觉到您错误概念card.php
,因为它应该是card.php
。 Laravel使用了许多PSR惯例和雄辩(处理关系和这些东西)。如果您不太了解它,请查看如何命名课程。正如Alireza所说,看看Laravel的文档,这是很棒而完整的。当您拥有一对多房地产时,其中一个应该具有Hasmany(...)
而不是You probrably have an error in your table name. For default, laravel will look for
cards
table name for a model namedCard
. Also, take a look in your models name. I espect you misstypecard.php
because it should beCard.php
. Laravel uses a lot of psr convention and Eloquent (who deal with relationships and that stuff). If you are not well versed into it, take a look in how to name classes. As Alireza said, take a look in the Laravel's documentation, it is awesome and complete. When you have a one to many realtionship, one of they should have ahasMany(...)
insteadbelongsTo(....)