From dc2a9a8762aecb9ce71b2e41ff05642a325014ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Mon, 25 Mar 2024 12:45:31 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0?= =?UTF-8?q?=BA=2025=20=D0=BC=D0=B0=D1=80=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Classes/LikesClass.php | 41 +++++ app/Http/Controllers/EmployerController.php | 26 +-- app/Http/Controllers/MainController.php | 53 +++++- app/Http/Controllers/WorkerController.php | 34 ++-- app/Models/Like_vacancy.php | 18 ++ app/Models/Like_worker.php | 25 +++ .../2024_03_24_082538_create_table_like_worker.php | 33 ++++ ...2024_03_24_082648_create_table_like_vacancy.php | 33 ++++ public/js/script145.js | 180 ++++++++++++++++++++ public/js/script45.js | 4 +- resources/views/employers/favorite.blade.php | 7 +- resources/views/js/favorite-vacancy-3.blade.php | 33 ++++ resources/views/js/favorite-vacancy-45.blade.php | 51 ++++++ resources/views/js/favorite-worker.blade.php | 51 ++++++ resources/views/layout/frontend.blade.php | 2 +- resources/views/list_vacancies.blade.php | 4 +- resources/views/resume.blade.php | 5 +- resources/views/vacance-item.blade.php | 3 +- resources/views/workers/cabinet.blade.php | 11 ++ resources/views/workers/favorite.blade.php | 8 +- routes/web.php | 5 + 21 files changed, 583 insertions(+), 44 deletions(-) create mode 100644 app/Classes/LikesClass.php create mode 100644 app/Models/Like_vacancy.php create mode 100644 app/Models/Like_worker.php create mode 100644 database/migrations/2024_03_24_082538_create_table_like_worker.php create mode 100644 database/migrations/2024_03_24_082648_create_table_like_vacancy.php create mode 100644 public/js/script145.js create mode 100644 resources/views/js/favorite-vacancy-3.blade.php create mode 100644 resources/views/js/favorite-vacancy-45.blade.php create mode 100644 resources/views/js/favorite-worker.blade.php diff --git a/app/Classes/LikesClass.php b/app/Classes/LikesClass.php new file mode 100644 index 0000000..d4f2dbf --- /dev/null +++ b/app/Classes/LikesClass.php @@ -0,0 +1,41 @@ +where('code_record', '=', $ad_employer->id)->get(); + return $ListVacancy; + } + + // Вывод всех избранных работников у пользователя + public static function ListWorkers(Worker $worker) { + $ListWorker = Like_worker::query()->where('code_record', '=', $worker->id)->get(); + } + + // Возвращение кода вакансии + public static function get_status_vacancy(Ad_employer $ad_employer) { + if (Like_vacancy::query()->where('code_record', '=', $ad_employer->id)->count() > 0) + $IdVacancy = " active "; + else + $IdVacancy = ""; + + return $IdVacancy; + } + + public static function get_status_worker(Worker $worker) { + if (Like_worker::query()->where('code_record', '=', $worker->id)->count() > 0) + { $IdWorker = " active"; } else { $IdWorker = "123"; } + + return $IdWorker; + } +} diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index d702c58..2e7687a 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -19,6 +19,8 @@ use App\Models\Employer; use App\Models\employers_main; use App\Models\Flot; use App\Models\Job_title; +use App\Models\Like_vacancy; +use App\Models\Like_worker; use App\Models\Message; use App\Models\Worker; use Carbon\Carbon; @@ -448,20 +450,20 @@ class EmployerController extends Controller //Избранные люди public function favorites(Request $request) { - if (isset($_COOKIE['favorite_worker'])) { - $items = RusDate::count_item_fav(); - $it = $_COOKIE['favorite_worker']; - $it = str_replace('"', "", $it); - $it = str_replace('[', "", $it); - $it = str_replace(']', "", $it); - $Arr = explode(",", $it); + $IP_address = RusDate::ip_addr_client(); + $Arr = Like_worker::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); + + if ($Arr->count()) { + $A = Array(); + foreach ($Arr as $it) { + $A[] = $it->code_record; + } + + $Workers = Worker::query()->whereIn('id', $A); } else { - $Arr = Array(); + $Workers = Worker::query(); } - $Workers = Worker::query(); - $Workers = $Workers->whereIn('id', $Arr); - if (($request->has('search')) && (!empty($request->get('search')))) { $search = $request->get('search'); @@ -584,7 +586,7 @@ class EmployerController extends Controller if (Auth::attempt($credentials)) { Auth::logout(); $it = User_Model::find($user_id); - //$it->delete(); + $it->delete(); return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); } else { return redirect()->route('employer.delete_people') diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index ad62f32..ddaa9e8 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Classes\RusDate; use App\Classes\Tools; use App\Mail\MailRegistration; use App\Mail\MailRepair; @@ -12,6 +13,8 @@ use App\Models\Education; use App\Models\Employer; use App\Models\employers_main; use App\Models\Job_title; +use App\Models\Like_vacancy; +use App\Models\Like_worker; use App\Models\News; use App\Models\reclame; use App\Models\User; @@ -75,6 +78,49 @@ class MainController extends Controller } } + // Лайк вакансии + public function like_vacancy(Request $request) { + $IP_address = RusDate::ip_addr_client(); + + if ($request->has('code_record')) { + if ($request->has('delete')) { + $atomic_era = Like_vacancy::select('id')-> + where('code_record', '=', $request-> + get('code_record'))->first(); + + DB::table('like_vacancy')->where('code_record', $request->get('code_record'))->delete(); + + } else { + $params = $request->all(); + $params['ip_address'] = $IP_address; + Like_vacancy::create($params); + } + } + } + + // Лайк соискателю. + public function like_worker(Request $request) { + $IP_address = RusDate::ip_addr_client(); + + if ($request->has('code_record')) { + if ($request->has('delete')) { + $atomic_era = Like_worker::select('id')-> + where('code_record', '=', $request-> + get('code_record'))->first(); + + DB::table('like_worker')->where('code_record', $request->get('code_record'))->delete(); + + return "Вот и результат удаления!"; + + } else { + $params = $request->all(); + $params['ip_address'] = $IP_address; + Like_worker::create($params); + } + } + } + + public function vacancies(Request $request) { //должности $Job_title = Job_title::query()->orderBy('name')->get(); @@ -124,6 +170,7 @@ class MainController extends Controller } $flot_prochee = $flot_prochee->groupby('ad_jobs.id')->get(); + if ($request->ajax()) { return view('ajax.new_sky', compact('categories', 'flot_paluba', 'flot_MO', 'flot_radovie', 'flot_prochee')); } else { @@ -157,9 +204,7 @@ class MainController extends Controller $Name_categori = ''; } - - - if ($request->get('sort')) { + if ($request->get('sort')) { $sort = $request->get('sort'); @@ -171,7 +216,7 @@ class MainController extends Controller case 'default': $Query = $Query->orderBy('id')->orderby('updated_at'); break; default: $Query = $Query->orderBy('id')->orderby('updated_at'); break; } - } + } $Job_title = Job_title::query()->OrderBy('name')->get(); diff --git a/app/Http/Controllers/WorkerController.php b/app/Http/Controllers/WorkerController.php index 8840325..d265918 100644 --- a/app/Http/Controllers/WorkerController.php +++ b/app/Http/Controllers/WorkerController.php @@ -11,6 +11,8 @@ use App\Models\Dop_info; use App\Models\Employer; use App\Models\infobloks; use App\Models\Job_title; +use App\Models\Like_vacancy; +use App\Models\Like_worker; use App\Models\Message; use App\Models\place_works; use App\Models\reclame; @@ -116,6 +118,11 @@ class WorkerController extends Controller } } + //Лайк резюме + public function like_controller() { + + } + // анкета соискателя public function resume_profile(Worker $worker) { @@ -387,7 +394,7 @@ class WorkerController extends Controller if (Auth::attempt($credentials)) { Auth::logout(); $it = User_Model::find($user_id); - //$it->delete(); + $it->delete(); return redirect()->route('index')->with('success', 'Вы успешно удалили свой аккаунт'); } else { return redirect()->route('worker.delete_profile') @@ -506,23 +513,22 @@ class WorkerController extends Controller } } - // Борьба против колорадских жуков, хотя жуков победил все таки 45. + // Вакансии избранные public function colorado(Request $request) { - if (isset($_COOKIE['favorit_vacancy'])) { - $items = RusDate::count_vacancy_fav(); - $it = $_COOKIE['favorit_vacancy']; - $it = str_replace('"', "", $it); - $it = str_replace('[', "", $it); - $it = str_replace(']', "", $it); - $Arr = explode(",", $it); + $IP_address = RusDate::ip_addr_client(); + $Arr = Like_vacancy::Query()->select('code_record')->where('ip_address', '=', $IP_address)->get(); + + if ($Arr->count()) { + $A = Array(); + foreach ($Arr as $it) { + $A[] = $it->code_record; + } + + $Query = Ad_employer::query()->whereIn('id', $A); } else { - $Arr = Array('$0'); + $Query = Ad_employer::query(); } - $Query = Ad_employer::Query(); - if (count($Arr) > 0) { - $Query = $Query->whereIn('id', $Arr); - } $Query = $Query->with('jobs')-> with('cat')-> with('employer')-> diff --git a/app/Models/Like_vacancy.php b/app/Models/Like_vacancy.php new file mode 100644 index 0000000..853ae06 --- /dev/null +++ b/app/Models/Like_vacancy.php @@ -0,0 +1,18 @@ +hasMany(Worker::class); + } +} diff --git a/database/migrations/2024_03_24_082538_create_table_like_worker.php b/database/migrations/2024_03_24_082538_create_table_like_worker.php new file mode 100644 index 0000000..aa2014f --- /dev/null +++ b/database/migrations/2024_03_24_082538_create_table_like_worker.php @@ -0,0 +1,33 @@ +id(); + $table->string('ip_address', 255)->nullable(false); + $table->string('code_record')->nullable(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('like_worker'); + } +}; diff --git a/database/migrations/2024_03_24_082648_create_table_like_vacancy.php b/database/migrations/2024_03_24_082648_create_table_like_vacancy.php new file mode 100644 index 0000000..3f11c1c --- /dev/null +++ b/database/migrations/2024_03_24_082648_create_table_like_vacancy.php @@ -0,0 +1,33 @@ +id(); + $table->string('ip_address', 255)->nullable(false); + $table->string('code_record')->nullable(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('table_like_vacancy'); + } +}; diff --git a/public/js/script145.js b/public/js/script145.js new file mode 100644 index 0000000..d77da3b --- /dev/null +++ b/public/js/script145.js @@ -0,0 +1,180 @@ +let scripts = function () { + + $('.js-toggle').on('click', function () { + $(this).toggleClass('active'); + }); + $('.js-parent-toggle').on('click', function () { + $(this).parent().toggleClass('active'); + }); + $('.js-parent-remove').on('click', function () { + $(this).parent().remove(); + }); + $('.js-menu-toggle').on('click', function () { + window.scrollTo(0, 0); + $('#body').toggleClass('menu-is-actived'); + }); + $('.js-cookies-close').on('click', function () { + $('#body').removeClass('cookies-is-actived'); + }); + $('.js-works-edit').on('click', function () { + $(this).parent().parent().parent().addClass('active'); + }); + $('.js-works-remove').on('click', function () { + $(this).parent().parent().parent().parent().remove(); + }); + + $('[data-tab]').on('click', function () { + $('[data-tab]').removeClass('active'); + $('[data-body]').removeClass('showed'); + $(this).addClass('active'); + var id = $(this).data('tab'); + $('[data-body=' + id + ']').addClass('showed'); + }); + + $('.js-password-show').on('click', function () { + $(this).parent().addClass('active'); + $(this).parent().parent().find('input').attr('type', 'text'); + }); + + $('.js-password-hide').on('click', function () { + $(this).parent().removeClass('active'); + $(this).parent().parent().find('input').attr('type', 'password'); + }); + + let checkScrollTop = function () { + if ($(document).scrollTop() == 0) { + $('#body').removeClass('begin'); + } else { + $('#body').addClass('begin'); + } + } + checkScrollTop(); + $(document).on('scroll', function () { + checkScrollTop(); + }); + + let closeAll = function () { + $('.js-toggle').removeClass('active'); + $('.js-parent-toggle').parent().removeClass('active'); + $('#body').removeClass('menu-is-actived'); + $('#body').removeClass('cookies-is-actived'); + } + + $(document).keyup(function (e) { + if (e.key === "Escape") { + closeAll(); + } + }); + + $('.js-scroll-to').bind('click', function (e) { + let anchor = $(this); + $('html,body').stop().animate({ + scrollTop: $(anchor.attr('href')).offset().top + }, 300); + e.preventDefault(); + }); + + if ($('[type=tel]').is('[type=tel]')) { + $('[type=tel]').mask('+7 (999) 999-99-99'); + } + + if ($('.js-select2').is('.js-select2')) { + $('.js-select2').select2(); + } + + const starRating = document.querySelectorAll(".js-stars"); + if (starRating.length) { + starRating.forEach(item => { + new StarRating(item); + }); + } +}; + +document.addEventListener("DOMContentLoaded", () => { + scripts(); + swipers(); +}); + +$(window).resize(function () { + swipers(); +}); + +let swipers = function () { + + if ($('.js-employer-swiper').is('.js-employer-swiper')) { + let slider = new Swiper('.js-employer-swiper', { + autoplay: { + delay: 5000, + }, + pagination: { + el: '.swiper-pagination', + clickable: true + }, + breakpoints: { + 768: { + slidesPerView: 2, + }, + 992: { + slidesPerView: 3, + }, + 1280: { + slidesPerView: 4, + }, + } + }); + } + + if ($('.js-news-swiper').is('.js-news-swiper')) { + let slider = new Swiper('.js-news-swiper', { + spaceBetween: 20, + pagination: { + el: '.swiper-pagination', + clickable: true + }, + navigation: { + prevEl: '.js-news-swiper-button-prev', + nextEl: '.js-news-swiper-button-next', + }, + breakpoints: { + 768: { + slidesPerView: 2, + }, + 992: { + slidesPerView: 3, + }, + } + }); + } + + // cookies + /*const cookieItems = document.querySelectorAll(".js-ck"); + if (cookieItems.length) { + cookieItems.forEach(item => { + const id = item.dataset.id; + const like = item.querySelector(".like"); + const checkLike = function () { + if (like.classList.contains("active")) { + Cookies.set('favor_vacan-'+id, id); + } else { + Cookies.remove(id); + } + } + + like.addEventListener("click", () => { + checkLike(); + }); + + if (Cookies.get('favor_vacan-'+id) == id) { + like.classList.add("active"); + } + }); + } + console.log(Cookies.get()); + + + */ +}; + + + + diff --git a/public/js/script45.js b/public/js/script45.js index 2f823da..ee76b51 100644 --- a/public/js/script45.js +++ b/public/js/script45.js @@ -147,7 +147,7 @@ let swipers = function () { } // cookies - const cookieItems = document.querySelectorAll(".js-ck"); + /*const cookieItems = document.querySelectorAll(".js-ck"); if (cookieItems.length) { cookieItems.forEach(item => { const id = item.dataset.id; @@ -171,6 +171,8 @@ let swipers = function () { } console.log(Cookies.get()); + + */ }; diff --git a/resources/views/employers/favorite.blade.php b/resources/views/employers/favorite.blade.php index 5e8fbce..c65e190 100644 --- a/resources/views/employers/favorite.blade.php +++ b/resources/views/employers/favorite.blade.php @@ -46,6 +46,7 @@ }); }); + @include('js.favorite-vacancy-45') @endsection @section('content') @@ -82,7 +83,7 @@ -
+
@if ($Query->count())
@@ -119,7 +119,7 @@
{{ $Q->created_at }}
-