LikesClass.php
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Classes;
use App\Models\Ad_employer;
use App\Models\Like_vacancy;
use App\Models\Like_worker;
use App\Models\Worker;
use Illuminate\Support\Facades\Auth;
class LikesClass
{
public static function ListVacancy(Ad_employer $ad_employer) {
$ListVacancy = Like_vacancy::query()
->where('code_record', '=', $ad_employer->id)
->where('user_id', Auth::user()?->id)
->get();
return $ListVacancy;
}
public static function ListWorkers(Worker $worker) {
$ListWorker = Like_worker::query()
->where('code_record', '=', $worker->id)
->where('user_id', Auth::user()?->id)
->get();
return $ListWorker;
}
public static function get_status_vacancy(Ad_employer $ad_employer) {
$isVacancyLiked = Like_worker::query()
->where('code_record', $ad_employer->id)
->where('user_id', Auth::user()?->id)
->exists();
if ($isVacancyLiked) {
return 'active';
}
return '';
}
public static function get_status_worker(Worker $worker) {
$isWorkerLiked = Like_worker::query()
->where('code_record', $worker->id)
->where('user_id', Auth::user()?->id)
->exists();
if ($isWorkerLiked) {
return 'active';
}
return '';
}
}