Passed
Push — bugfix/job_translation_fields ( dcec43...2ad85b )
by Tristan
14:10
created

ApplicationController::destroy()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Facades\Lang;
7
use Illuminate\Support\Facades\Auth;
8
use App\Models\JobApplication;
9
use App\Models\Skill;
10
11
class ApplicationController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicationController
Loading history...
12
{
13
    /**
14
     * Display a listing of the resource.
15
     *
16
     * @return \Illuminate\Http\Response
17
     */
18
    public function index()
19
    {
20
        $applications = Auth::user()->applicant->job_applications;
0 ignored issues
show
Bug introduced by
Accessing applicant on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
21
        return view('applicant/application_index', [
1 ignored issue
show
Bug Best Practice introduced by
The expression return view('applicant/a...=> '/images/user.png')) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
22
            "application_index" => Lang::get('applicant/application_index'),
23
            "applications" => $applications,
24
            "departments_template" => Lang::get('common/lookup/departments'),
25
            "manager_profile_photo" => '/images/user.png', //TODO: get real photo
26
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
27
    }
28
29
30
    /**
31
     * Display specified application
32
     *
33
     * @param  \App\Models\JobApplication  $application
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
34
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
35
     */
36
    public function show(JobApplication $application)
37
    {
38
        $criteria = [
39
            'essential' => $application->job_poster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
            'essential' => $application->job_poster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
40
                return $value->criteria_type->name == 'essential';
41
            }),
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
42
            'asset' => $application->job_poster->criteria->filter(function($value, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

42
            'asset' => $application->job_poster->criteria->filter(function($value, /** @scrutinizer ignore-unused */ $key) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
43
                return $value->criteria_type->name == 'asset';
44
            }),
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
45
        ];
46
47
        return view('common/application_preview', [
1 ignored issue
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Bug Best Practice introduced by
The expression return view('common/appl...tion' => $application)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
48
49
            /* Application Template Data */
50
                "application_template" => Lang::get("applicant/application_template"),
51
                "application_preview" => true,
52
                "preferred_language_template" => Lang::get('common/preferred_language'),
53
                "citizenship_declaration_template" => Lang::get('common/citizenship_declaration'),
54
                "veteran_status_template" => Lang::get('common/veteran_status'),
55
56
            /* Job Data */
57
                "job" => $application->job_poster,
58
59
            /* Skills Data */
60
                "skills" => Skill::all(),
61
                "skill_template" => Lang::get("common/skills"),
62
                'reference_template' => Lang::get('common/references'),
63
                'sample_template' => Lang::get('common/work_samples'),
64
                "criteria" => $criteria,
65
66
            /* Applicant Data */
67
                "applicant" => $application->applicant,
68
                "job_application" => $application,
69
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
70
    }
71
72
    /**
73
     * Delete the particular resource from storage.
74
     *
75
     * @param  \Illuminate\Http\Request  $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 2 found
Loading history...
76
     * @param  \App\Models\JobApplication  $application
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
77
     * @return \Illuminate\Http\Response
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
78
     */
79
    public function destroy(Request $request, JobApplication $application)
80
    {
81
        $this->authorize('delete', $application);
82
83
        $application->delete();
84
85
        if($request->ajax()) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
86
            return [
1 ignored issue
show
Bug Best Practice introduced by
The expression return array('message' => 'Application deleted') returns the type array<string,string> which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
87
                "message" => 'Application deleted'
88
            ];
89
        }
90
91
        return redirect()->back();
1 ignored issue
show
Bug Best Practice introduced by
The expression return redirect()->back() returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
92
    }
93
94
}
95