diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 8b2cd33..c796fdc 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -9,6 +9,7 @@ use App\Models\Ad_employer; use App\Models\Category; use App\Models\Education; use App\Models\Employer; +use App\Models\employers_main; use App\Models\Job_title; use App\Models\News; use App\Models\reclame; @@ -32,7 +33,8 @@ class MainController extends Controller ->GroupBy('categories.id') ->get(); - $employers = Employer::query()->orderBy('id')->limit(20)->get(); + $employers = employers_main::query()->with('employer')->orderBy('id')->limit(8)->get(); + return view('index', compact('news', 'categories', 'employers')); } diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index c35aefe..fdbb4cd 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -102,20 +102,22 @@ @php $rec = 0; $count = $employers->count(); + @endphp + @foreach($employers as $emp) @php $rec++ @endphp @if (($rec==1) || ($rec==5) || ($rec==9) || ($rec==13) || ($rec==17))
@endif - @if (!empty($emp->logo)) - - {{ $emp->name_company }} + @if (!empty($emp->employer->logo)) + + {{ $emp->employer->name_company }} @else - - {{ $emp->name_company }} + + {{ $emp->employer->name_company }} @endif @if (($rec==4) || ($rec==8) || ($rec==12) || ($rec==16) || ($rec==20) || ($rec == $count))