我有如下代码如何在Laravel中过滤收藏?
$tecnico = Tecnico::with('servicios')->where('Auth_Token',$auth)->firstOrFail();
if($tecnico != ''){
$servicios = $tecnico->servicios;
$servicio = $servicios->where('idServicio', $id);
}
的Servicio
有很多Tecnico
和Tecnico
有很多Service
在这种情况下,我只需要从Auth_token
后来也Tecnico
需要通过从Tecnico
但过滤器的所有Servicio
id
当我运行上面的代码以下错误
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to undefined method Illuminate\Database\Eloquent\Collection::where()
在$servicio = $servicios->where('idServicio', $id);
我该如何解决?
THX对您有所帮助,它的工作:d – cheloncio
欢迎您@zhelon :-) –