This is my code:
这是我的代码:
$get_all = Geo_Postal_us::findOrFail($postal);
With this query,laravel
try to find ID filed in table.
通过此查询,laravel尝试在表中查找ID。
I don't have id filed, for primary key i have postal column.
我没有id提交,对于主键我有邮政专栏。
So, how to set function to find value in postal column, not to search from id column ?
那么,如何设置函数在邮政列中查找值,而不是从id列中搜索?
Thanks,
谢谢,
1 个解决方案
#1
22
You could create the behaviour you are looking for with the following:
您可以使用以下内容创建您要查找的行为:
Geo_Postal_us::where('postal', $postal)->firstOrFail();
#1
22
You could create the behaviour you are looking for with the following:
您可以使用以下内容创建您要查找的行为:
Geo_Postal_us::where('postal', $postal)->firstOrFail();