1 | <?php |
||||
2 | |||||
3 | namespace App\Mail; |
||||
4 | |||||
5 | use App\Models\JobPoster; |
||||
6 | use App\Models\Lookup\CitizenshipDeclaration; |
||||
7 | use App\Models\Lookup\VeteranStatus; |
||||
8 | use App\Models\User; |
||||
9 | use Illuminate\Bus\Queueable; |
||||
10 | use Illuminate\Mail\Mailable; |
||||
11 | use Illuminate\Queue\SerializesModels; |
||||
12 | use Illuminate\Contracts\Queue\ShouldQueue; |
||||
13 | use Illuminate\Support\Facades\App; |
||||
14 | use Illuminate\Support\Facades\Config; |
||||
15 | use Illuminate\Support\Facades\Lang; |
||||
16 | use Illuminate\Support\Facades\Log; |
||||
17 | use Jenssegers\Date\Date; |
||||
18 | use Mcamara\LaravelLocalization\Facades\LaravelLocalization; |
||||
19 | |||||
20 | class ScreenCandidatesPrompt extends Mailable implements ShouldQueue |
||||
21 | { |
||||
22 | use Queueable, SerializesModels; |
||||
23 | |||||
24 | /** |
||||
25 | * The Job Poster instance. |
||||
26 | * |
||||
27 | * @var JobPoster |
||||
28 | */ |
||||
29 | public $job; |
||||
30 | |||||
31 | /** |
||||
32 | * Create a new message instance. |
||||
33 | * |
||||
34 | * @return void |
||||
35 | */ |
||||
36 | public function __construct(JobPoster $job) |
||||
37 | { |
||||
38 | $this->job = $job; |
||||
39 | } |
||||
40 | |||||
41 | /** |
||||
42 | * Build the message. |
||||
43 | * |
||||
44 | * @return $this |
||||
45 | */ |
||||
46 | public function build() |
||||
47 | { |
||||
48 | // Get emails of all Hr Advisors who have claimed job. |
||||
49 | $hr_advisors_emails = []; |
||||
50 | $hr_advisors = $this->job->hr_advisors; |
||||
51 | |||||
52 | foreach ($hr_advisors as $advisor) { |
||||
53 | $email = User::where('id', $advisor->user_id)->first()->email; |
||||
54 | array_push($hr_advisors_emails, $email); |
||||
55 | } |
||||
56 | |||||
57 | // Get date 2 weeks after job poster closes. |
||||
58 | $date_in_two_weeks = humanizeLastDay($this->job->close_date_time->addWeeks(2), 'en'); |
||||
59 | $date_in_two_weeks_fr = humanizeLastDay($this->job->close_date_time->addWeeks(2), 'fr'); |
||||
60 | |||||
61 | // Number of applicants. |
||||
62 | $num_of_applicants = $this->job->submitted_applications->count(); |
||||
63 | |||||
64 | // Number of non-citizens. |
||||
65 | $canadian_citizen = CitizenshipDeclaration::where('name', 'citizen')->first()->id; |
||||
66 | $num_of_noncitizens = $this->job->submitted_applications |
||||
67 | ->where('citizenship_declaration_id', '!=', $canadian_citizen) |
||||
68 | ->count(); |
||||
69 | |||||
70 | // Number of veterans. |
||||
71 | $non_veteran = VeteranStatus::where('name', 'none')->first()->id; |
||||
72 | $num_of_veterans = $this->job->submitted_applications |
||||
73 | ->where('veteran_status_id', '!=', $non_veteran) |
||||
74 | ->count(); |
||||
75 | |||||
76 | $position = $this->job->getTranslations('title'); |
||||
77 | $classification = $this->job->getClassificationMessageAttribute(); |
||||
78 | $subject = Lang::get('common/notifications/screen_candidates.subject', [ 'position' => $position['en'], 'classification' => $classification ], 'en') |
||||
79 | . ' / ' |
||||
80 | . Lang::get('common/notifications/screen_candidates.subject', [ 'position' => $position['fr'], 'classification' => $classification ], 'fr'); |
||||
81 | |||||
82 | return $this->subject($subject) |
||||
83 | ->cc($hr_advisors_emails) |
||||
84 | ->cc(config('mail.admin_address')) |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
85 | ->markdown('emails.job_posters.screen_candidates_plain', [ |
||||
86 | 'drop_off_date' => [ |
||||
87 | 'en' => $date_in_two_weeks, |
||||
88 | 'fr' => $date_in_two_weeks_fr, |
||||
89 | ], |
||||
90 | 'manager_portal_link' => [ |
||||
91 | 'en' => LaravelLocalization::getLocalizedURL('en', route('manager.home')), |
||||
0 ignored issues
–
show
The function
route was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
92 | 'fr' => LaravelLocalization::getLocalizedURL('fr', route('manager.home')), |
||||
93 | ], |
||||
94 | 'num_of_applicants' => $num_of_applicants, |
||||
95 | 'num_of_noncitizens' => $num_of_noncitizens, |
||||
96 | 'num_of_veterans' => $num_of_veterans, |
||||
97 | 'position' => $position, |
||||
98 | 'position_link' => [ |
||||
99 | 'en' => LaravelLocalization::getLocalizedURL('en', route('jobs.summary', $this->job->id)), |
||||
100 | 'fr' => LaravelLocalization::getLocalizedURL('fr', route('jobs.summary', $this->job->id)), |
||||
101 | ], |
||||
102 | 'talent_cloud_email' => config('mail.admin_address'), |
||||
103 | ]); |
||||
104 | } |
||||
105 | } |
||||
106 |