This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
This post was edited and submitted for review 2 years ago and failed to reopen the post:
Original close reason(s) were not resolved
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
这个语法是不正确的!
阅读此文档以获取():
https://laravel.com/docs/docs/9.x/eloquent#检索单个模式
阅读此文档有关():
<条款
我的描述:
当您想找到一个product_category行时,必须编写此(例如,使用ID 7的product_category):
或
当您使用时
first()
函数在代码末尾,它返回一行,这是第一行。在代码末尾使用get()
函数时,它返回查询中的一组行。当您使用
find()
且其返回值为null时,您无法调用where()
之后!我认为您必须这样写您的控制器:
我建议您读过有关Laravel的雄辩:
https://laravel.com/docs/9.x/eloquent
以及关于Laravel查询构建器:
https://laravel.com/docs/9.x/ceries
this syntax is not correct!
read this document for find():
https://laravel.com/docs/9.x/eloquent#retrieving-single-models
read this document for where():
https://laravel.com/docs/9.x/queries#where-clauses
my description:
when you want to find a single product_category row you must write this (for example product_category with id 7):
or
when you use
first()
function at the end of your code, its return a single row and that is the first row. when usingget()
function at the end of your code, its return a set of rows that are in your Query.when you use
find()
and its return value is null, you cant callwhere()
after that!I think you must write your controller like this:
I suggest you read about Laravel Eloquent much:
https://laravel.com/docs/9.x/eloquent
and about Laravel Query builder:
https://laravel.com/docs/9.x/queries