Laravel 6 ErrorException Undefined variable: user (…home.blade.php)

I am trying to show every user’s name from the database in the home.blade.php. I am getting this error:

ErrorException
Undefined variable: user (View...home.blade.php)

$user is undefined
Make the variable optional in the blade template. Replace {{ $user }} with {{ $user ?? '' }}

Below is the code in home.blade.php:

<!-- SQL statement select all profiles except logged user -->

foreach ($user as $users)
   <h6>{{ $user->name }}</h6>
endforeach

Below is the code in HomeController.php

public function index()
    {
        $users = Users::where('id', '!=', auth()->id())->get();

        return view('home');
    }

Answer

In your HomeController.php

return view('home', ['users' => $users]);

And your foreach should be:

@foreach($users as $user)
     <h6>{{ $user->name }}</h6>
@endforeach