Relationship Eloquent do Laravel

1

I have 3 tables:

-- tipos
id
nome

-- usuarios
id
tipo_id
nome
email

-- atividades
id
usuario_id
descricao

I'm using Eloquent to capture activity and user data from the activity:

$results = Atividades::with('Usuario')->get();

But I need to get the user type as well, I've tried:

$results = Atividades::with('Usuario')->with('Tipo')->get();

But it does not return user type data, only user data, would anyone know how to do this query?

    
asked by anonymous 13.01.2016 / 21:48

1 answer

1

You can put more than one parameter in the with method, do the following:

$results = Atividades::with('Usuario', 'Tipo')->get();

To confirm you can check the laravel documentation.

    
13.01.2016 / 22:24