Laravel – Help with models and displaying data

I am learning Laravel and I am trying to show all users that are not part of the team already.

I have 3 database tables:

users
teams
team_members

The users table have the following columns:

id
first_name
last_name
password
email
created_at
updated_at

The teams table has these columns

id
user_id
team_id

I have 3 models: User, Team, and TeamMember

The User model has this code:

public function teamMembers()
{
// A user can be a member of many teams
return $this->hasMany(TeamMember::class);
}

The Team model has this code:

public function teamMember()
{
// A team member can be part of many teams
return $this->hasMany(TeamMember::Class);
}

And the TeamMember model has this code:

public function team()
{
return $this->belongsTo(Team::class);
}

public function user()
{
return $this->belongsTo(User::class);
}

The TeamMemberController is providing the data to the view (route: admin/teams/{team}/members). Right now it has this code:

// Used to allow the admin to select members to add to a team
public function index(Team $team){

// Goal: only return members that are NOT in the team yet

// $members = $team->teamMember->user->all();
// dd($members);

return view(‘admin.teams.members.index’)->with([
‘users’ => User::all(),
‘team’ => $team
]);

}