Passed
Push — feature/job-summary-hr ( 67ecfb )
by Grant
13:42
created

HomepageController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 22
dl 0
loc 51
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A applicant() 0 23 1
A manager() 0 4 1
A hr_advisor() 0 4 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Support\Facades\Lang;
6
use App\Http\Controllers\Controller;
7
use App\Models\JobPoster;
8
use Carbon\Carbon;
9
10
class HomepageController extends Controller
11
{
12
    /**
13
     * Show the applicant home page.
14
     * @return \Illuminate\Http\Response
15
     */
16
    public function applicant()
17
    {
18
        $now = Carbon::now();
19
20
        // Find three most recent published jobs that are currently open for applications.
21
        // Eager load required relationships: Department, Province, JobTerm.
22
        $jobs = JobPoster::where('open_date_time', '<=', $now)
23
            ->where('close_date_time', '>=', $now)
24
            ->where('published', true)
25
            ->with([
26
                'department',
27
                'province',
28
            ])
29
            ->orderBy('open_date_time', 'desc')
30
            ->take(3)
31
            ->get();
32
        return view('applicant/home', [
33
            'home' => Lang::get('applicant/home'),
34
            'hero' => Lang::get('common/hero'),
35
            'job_index' => Lang::get('applicant/job_index'),
36
            'job_post' => Lang::get('applicant/job_post'),
37
            'jobs' => $jobs,
38
            'job_count' => count($jobs)
39
        ]);
40
    }
41
42
    /**
43
     * Show the manager home page.
44
     * @return \Illuminate\Http\Response
45
     */
46
    public function manager()
47
    {
48
        return view('manager/home', [
49
            'home_l10n' => Lang::get('manager/home'),
50
        ]);
51
    }
52
53
    /**
54
     * Show the hr_advisor home page.
55
     * @return \Illuminate\Http\Response
56
     */
57
    public function hr_advisor() //phpcs:ignore
58
    {
59
        return view('hr_advisor/home', [
60
            'hr_home' => Lang::get('hr_advisor/home'),
61
        ]);
62
    }
63
}
64