属性[]在使用与laravel的一对多关系的雄辩构建器实例上不存在
我使用的是Laravel7。 我有两个表:属性[]在使用与laravel的一对多关系的雄辩构建器实例上不存在,laravel,Laravel,我使用的是Laravel7。 我有两个表:request\u properties和requests请求属性可能有许多请求(请求中的FK是请求属性id)。 我想使用模型中的一对多关系返回表请求的所有id从表请求属性的id开始,但我收到以下错误: Property [reqs] does not exist on the Eloquent builder instance. 这是我的控制器中的代码: return Request_property::where('id', 71979)->
request\u properties
和requests
<代码>请求属性可能有许多请求
(请求
中的FK是请求属性id
)。
我想使用模型中的一对多关系返回表请求的所有id
从表请求属性的id
开始,但我收到以下错误:
Property [reqs] does not exist on the Eloquent builder instance.
这是我的控制器中的代码:
return Request_property::where('id', 71979)->reqs->id;
以下是我的模型中的方法:
Req.php
public function request_property()
{
return $this->belongsTo('App\Request_property', 'id', 'request_properties_id');
}
Request_property.php
public function reqs()
{
return $this->hasMany('App\Req', 'request_properties_id', 'id');
}
使用
Request_属性::where('id',71979)->first()->reqs()->pull('id');
然后使用get-all-id ofreqs()