LikesClass.php 1.26 KB
<?php


namespace App\Classes;


use App\Models\Ad_employer;
use App\Models\Like_vacancy;
use App\Models\Like_worker;
use App\Models\Worker;

class LikesClass
{
    // Вывод всех избранных вакансий у пользователя
    public static function ListVacancy(Ad_employer $ad_employer) {
        $ListVacancy = Like_vacancy::query()->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;
    }
}