@azizbek29 Try this:
In your Vacancy model:
public function users()
{
return $this->hasManyThrough(User::class, Vacancy::class);
}
Update your index model:
public function index()
{
$contests = Contest::with('vacancies')->get();
return view('contests.index', compact('contests'));
}
In the view:
@foreach($contests as $contest)
<tr>
<td>1</td>
<td>{{ $contest->name }}</td>
<td>{{ date('d.m.Y', strtotime($contest->from)) }}</td>
<td>{{ date('d.m.Y', strtotime($contest->until)) }}</td>
<td>{{ $contest->vacancies->count() }}</td>
<td>{{ $contest->users->count() }}</td>
<td>75 ta</td>
</tr>
@endforeach