我有如下代碼如何在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 :-) –