I am trying to generate a query with related tables, I have a call deposits, which keeps the id of other 4 tables, users, states, banks and types, but when I do the query, I only manage to bring the ids of the others tables, and not the names, I already have the relationships in the models.
Now I explain the problem better, if I make a general query, regardless of the user who made the deposit, if I can bring the data I need, the problem is when I only want to bring the deposits of a specific user, because there only I bring the ids of the other tables, and not the names that is what interests me.
At the moment I have my query as follows:
public function index()
{
$depositos = DB::table('depositos')
->select('depositos.*','depositos.id as id_deposito', 'depositos.monto','depositos.fechaboleta','depositos.detalles','depositos.observaciones','depositos.created_at','depositos.updated_at','depositos.noboleta')
->where( 'id_usuario','=', Auth::id())
->join('bancos','bancos.id','=','depositos.id_banco')
->join('tipos','tipos.id','=','depositos.id_tipo')
->join('estados','estados.id','=','depositos.id_estado')
->paginate(5);
return view('depositos.index', compact('depositos'));
}
If someone can help me, I would really appreciate it.