here i am trying to get all the project->id, which match with team->project_id and relation is working but my using variable $users showing undefined. What could be the problem??
here is the controller code
public function index()
{
if (Auth::user()->role->id == 1) {
$projects = Project::all();
$teams = Team::all();
foreach ($teams as $team) {
$users = User::whereIn('id', $team->members)->get();
}
return view('project.index', compact('projects', 'users'));
}
}