Get join values Laravel

According documentation about joins:

As example:

$users = DB::table('users')
            ->join('contacts', '', '=', 'contacts.user_id')
            ->join('orders', '', '=', 'orders.user_id')
            ->select('users.*', '', 'orders.price')

OK, I have my values into $users. If I do, with blade:

{{ $users }}

I can see this result, in JSON format. But, How can I get each single value, using Blade? (Ex:, or orders.price, in this example)

Thanks on advance

1 answer

  • answered 2021-04-14 22:25 kemp

    @foreach($users as $user)
        {{ $user }}

    You can substitute $user with any variable you wish.

    Docs: Laravel