Commit 2a7870bed35f30735467ae9c4c77a35491a5a97e
1 parent
6370754b6b
Exists in
master
and in
1 other branch
Обновление главной страницы
Showing 2 changed files with 10 additions and 6 deletions Side-by-side Diff
app/Http/Controllers/MainController.php
... | ... | @@ -9,6 +9,7 @@ use App\Models\Ad_employer; |
9 | 9 | use App\Models\Category; |
10 | 10 | use App\Models\Education; |
11 | 11 | use App\Models\Employer; |
12 | +use App\Models\employers_main; | |
12 | 13 | use App\Models\Job_title; |
13 | 14 | use App\Models\News; |
14 | 15 | use App\Models\reclame; |
... | ... | @@ -32,7 +33,8 @@ class MainController extends Controller |
32 | 33 | ->GroupBy('categories.id') |
33 | 34 | ->get(); |
34 | 35 | |
35 | - $employers = Employer::query()->orderBy('id')->limit(20)->get(); | |
36 | + $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); | |
37 | + | |
36 | 38 | |
37 | 39 | return view('index', compact('news', 'categories', 'employers')); |
38 | 40 | } |
resources/views/index.blade.php
... | ... | @@ -102,20 +102,22 @@ |
102 | 102 | @php |
103 | 103 | $rec = 0; |
104 | 104 | $count = $employers->count(); |
105 | + | |
105 | 106 | @endphp |
107 | + | |
106 | 108 | @foreach($employers as $emp) |
107 | 109 | @php $rec++ @endphp |
108 | 110 | @if (($rec==1) || ($rec==5) || ($rec==9) || ($rec==13) || ($rec==17)) |
109 | 111 | <div class="swiper-slide"> |
110 | 112 | <div class="employer__item"> |
111 | 113 | @endif |
112 | - @if (!empty($emp->logo)) | |
113 | - <a href="{{ route('ad-employer', ['ad_employer' => $emp->id]) }}"> | |
114 | - <img src="{{ asset(Storage::url($emp->logo)) }}" alt="{{ $emp->name_company }}"> | |
114 | + @if (!empty($emp->employer->logo)) | |
115 | + <a href="{{ route('ad-employer', ['ad_employer' => $emp->employer->id]) }}"> | |
116 | + <img src="{{ asset(Storage::url($emp->employer->logo)) }}" alt="{{ $emp->employer->name_company }}"> | |
115 | 117 | </a> |
116 | 118 | @else |
117 | - <a href="{{ route('ad-employer', ['ad_employer' => $emp->id]) }}"> | |
118 | - <img src="{{ asset('images/logo_emp.png') }}" alt="{{ $emp->name_company }}"> | |
119 | + <a href="{{ route('ad-employer', ['ad_employer' => $emp->employer->id]) }}"> | |
120 | + <img src="{{ asset('images/logo_emp.png') }}" alt="{{ $emp->employer->name_company }}"> | |
119 | 121 | </a> |
120 | 122 | @endif |
121 | 123 | @if (($rec==4) || ($rec==8) || ($rec==12) || ($rec==16) || ($rec==20) || ($rec == $count)) |