diff --git a/app/Classes/Cookies_vacancy.php b/app/Classes/Cookies_vacancy.php index 1cc4e24..d5194fb 100644 --- a/app/Classes/Cookies_vacancy.php +++ b/app/Classes/Cookies_vacancy.php @@ -9,10 +9,10 @@ use DateTime; class Cookies_vacancy { public static function selected_vacancy($item) { - if (empty($_COOKIE['favorite_vacancy'])) + if (empty($_COOKIE['favorit_vacancy'])) return ""; else { - $Str = json_decode($_COOKIE['favorite_vacancy'], true); + $Str = json_decode($_COOKIE['favorit_vacancy'], true); //$Arr = explode(",", $Str); if (in_array($item, $Str)) return " active "; @@ -23,11 +23,11 @@ class Cookies_vacancy // Вывод избранных вакансий public static function count_vacancy_fav() { - if (empty($_COOKIE['favorite_vacancy'])) + if (empty($_COOKIE['favorit_vacancy'])) return 0; else { - $Arr = json_decode($_COOKIE['favorite_vacancy'], true); + $Arr = json_decode($_COOKIE['favorit_vacancy'], true); return count($Arr); @@ -36,8 +36,8 @@ class Cookies_vacancy // Удаление избранных вакансий public static function clear_vacancy() { - if (!empty($_COOKIE['favorite_vacancy'])) - unset($_COOKIE['favorite_vacancy']); + if (!empty($_COOKIE['favorit_vacancy'])) + unset($_COOKIE['favorit_vacancy']); } } diff --git a/app/Classes/RusDate.php b/app/Classes/RusDate.php index 2090dfe..f787114 100644 --- a/app/Classes/RusDate.php +++ b/app/Classes/RusDate.php @@ -61,10 +61,10 @@ class RusDate } // Избранные вакансии public static function selected_vacancy($item) { - if (empty($_COOKIE['favorite_vac'])) + if (empty($_COOKIE['favorit_vacancy'])) return ""; else { - $Str = json_decode($_COOKIE['favorite_vac'], true); + $Str = json_decode($_COOKIE['favorit_vacancy'], true); //$Arr = explode(",", $Str); if (in_array($item, $Str)) return " active "; @@ -135,11 +135,11 @@ class RusDate // Вывод избранных вакансий public static function count_vacancy_fav() { - if (empty($_COOKIE['favorite_vac'])) + if (empty($_COOKIE['favorit_vacancy'])) return 0; else { - $Arr = json_decode($_COOKIE['favorite_vac'], true); + $Arr = json_decode($_COOKIE['favorit_vacancy'], true); return count($Arr); @@ -148,8 +148,8 @@ class RusDate // Удаление избранных вакансий public static function clear_vacancy() { - if (!empty($_COOKIE['favorite_vac'])) - unset($_COOKIE['favorite_vac']); + if (!empty($_COOKIE['favorit_vacancy'])) + unset($_COOKIE['favorit_vacancy']); } } diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index 97fcd92..d702c58 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -38,7 +38,6 @@ class EmployerController extends Controller { public function vacancie($vacancy, Request $request) { $title = 'Заголовок вакансии'; - $Query = Ad_employer::with('jobs')-> with('cat')-> with('employer')-> @@ -46,12 +45,15 @@ class EmployerController extends Controller select('ad_employers.*')-> where('id', '=', $vacancy)->get(); + if (isset(Auth()->user()->id)) + $uid = Auth()->user()->id; + else + $uid = 0; $title = $Query[0]->name; - if ($request->ajax()) { - return view('ajax.vacance-item', compact('Query')); + return view('ajax.vacance-item', compact('Query','uid')); } else { - return view('vacance-item', compact('title', 'Query')); + return view('vacance-item', compact('title', 'Query', 'uid')); } } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index 8906a12..06285da 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -118,23 +118,26 @@ class MainController extends Controller with('cat')-> with('employer')-> whereHas('jobs_code', function ($query) use ($request) { - if ($request->ajax()) { if (null !== ($request->get('job')) && ($request->get('job') !== 0)) { $query->where('job_title_id', $request->get('job')); } - } }) ->select('ad_employers.*'); - - if ($categories->id > 0) { + if (isset($categories->id) && ($categories->id > 0)) { $Query = $Query->where('category_id', '=', $categories->id); $Name_categori = Category::query()->where('id', '=', $categories->id)->get(); + } else { + $Name_categori = ''; } + + if ($request->get('sort')) { $sort = $request->get('sort'); + + switch ($sort) { case 'name_up': $Query = $Query->orderBy('name')->orderBy('id'); break; case 'name_down': $Query = $Query->orderByDesc('name')->orderby('id'); break; diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index b856109..c0bf1ba 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -497,15 +497,15 @@ class WorkerController extends Controller // Борьба против колорадских жуков, хотя жуков победил все таки 45. public function colorado(Request $request) { - if (isset($_COOKIE['favorite_vac'])) { + if (isset($_COOKIE['favorit_vacancy'])) { $items = RusDate::count_vacancy_fav(); - $it = $_COOKIE['favorite_vac']; + $it = $_COOKIE['favorit_vacancy']; $it = str_replace('"', "", $it); $it = str_replace('[', "", $it); $it = str_replace(']', "", $it); $Arr = explode(",", $it); } else { - $Arr = Array(); + $Arr = Array('$0'); } $Query = Ad_employer::Query(); diff --git a/resources/views/ajax/list_vacancies.blade.php b/resources/views/ajax/list_vacancies.blade.php index 6cbb7ce..ca92508 100644 --- a/resources/views/ajax/list_vacancies.blade.php +++ b/resources/views/ajax/list_vacancies.blade.php @@ -1,82 +1,118 @@ -@if ($Query->count()) +@php $i = ($Query->currentPage() * $Query->perPage() - $Query->count() - 1) @endphp + @foreach ($Query as $Q) -