I need to do a query using Eloquent on a couple of tables that are 1-to-many related and I'm not able to figure it out. Here is the code I am using:
$datos = Vigelectrodetenida::query()
->with('relUsr')
->where('cam1b', 'LIKE', '%' . $this->busquedas . '%')
->orWhere('cam1c','LIKE', '%' . $this->busquedas . '%')
->orderBy($this->campOrden, $this->direcOrden)
->paginate(20);
I use this code to generate a table that has a lookup input using livewire. For now, the queries I make on the cam1b or cam1c field work fine, but when I want to put another orWhere and have it act on the name field that is in the users table (relUsr) it stops working, it tells me that the name field. Next I put the code that I am using and the error that is being generated.
$datos = Vigelectrodetenida::query()
->with('relUsr')
->where('cam1b', 'LIKE', '%' . $this->busquedas . '%')
->orWhere('cam1c','LIKE', '%' . $this->busquedas . '%')
->orWhere('name','LIKE', '%' . $this->busquedas . '%')
->orderBy($this->campOrden, $this->direcOrden)
->paginate(20);
Well, I hope I have been able to convey my doubt correctly and that you can help me.
I want to thank @HeytalePazguato for his valuable help