hello I have two models Movement and Account
In the Movement model I have the following relationship.
public function cuenta()
{
return $this->hasOne(Cuenta::class);
}
What I am looking for is to bring all the Movements with their Account relation, in the consultation with Account they must comply with the name of the bank, and the name of the holder.
The detail is in the holder of the account, the 'LIKE' and the wild cards of the last WHERE does not work and does not find any co-residence.
$movimientos = Movimiento::where('fecha', $fecha)
->where('status','NUEVO')->with('cuenta')->get()
->where('cuenta.banco', $banco)
->where('cuenta.titular','LIKE','%'.$titular.'%');
If I remove the 'like' and the wildcards and pass the variable $ holder as it is in the database if you return the corresponding records.
$movimientos = Movimiento::where('fecha', $fecha)
->where('status','NUEVO')->with('cuenta')->get()
->where('cuenta.banco', $banco)
->where('cuenta.titular', $titular);