Capture ID eloquently on JOIN

Asked

Viewed 15 times

0

Good afternoon everyone, I have the following appointment:

$acordo = tb_acordo::join('users', 'users_id', '=', 'users.id')
                            ->join('tb_status_acordos', 'tb_status_acordos_id', '=', 'tb_status_acordos.id')
                            ->join('tb_carteiras', 'tb_carteira_id', '=', 'tb_carteiras.id')
                            ->where('users_id', $id_user )
                            ->orderBy('data_acordo', 'desc')
                            ->get();

But in the view when I capture the ID this way: {{$acordos->id}} it brings me the table id users and need table tb_agreement, someone help with this query please?

  • You can use the ->select(), take a look at the link of the documentation https://laravel.com/docs/5.8/queries#joins

  • Man, I forgot about Select, got a lot of thanks

1 answer

0


Just to close the topic.

You may not always want to select all columns of a database table. Using the select method, you can specify a custom selection clause for the query:

You can use the : ->selecte()

To be able to tell which fields you really want to see.

Follow the documentation link.select()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.