EarningController::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
namespace App\Http\Controllers\OpenPayroll\Setting;
4
5
use App\Http\Controllers\Controller;
0 ignored issues
show
Bug introduced by
The type App\Http\Controllers\Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use App\Models\OpenPayroll\EarningType;
7
use Illuminate\Http\Request;
8
9
class EarningController extends Controller
10
{
11
    /**
12
     * Display a listing of the resource.
13
     *
14
     * @return \Illuminate\Http\Response
15
     */
16
    public function index()
17
    {
18
    }
19
20
    /**
21
     * Show the form for creating a new resource.
22
     *
23
     * @return \Illuminate\Http\Response
24
     */
25
    public function create()
26
    {
27
        return view('open-payroll.settings.earning.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('open-payrol...ttings.earning.create') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
28
    }
29
30
    /**
31
     * Store a newly created resource in storage.
32
     *
33
     * @param \Illuminate\Http\Request $request
34
     *
35
     * @return \Illuminate\Http\Response
36
     */
37
    public function store(Request $request)
38
    {
39
        $this->validate($request, [
40
            'name' => 'required|min:3|max:255',
41
        ]);
42
43
        EarningType::create([
44
            'name'      => $request->name,
45
            'code'      => kebab_case($request->name, ''),
0 ignored issues
show
Unused Code introduced by
The call to kebab_case() has too many arguments starting with ''. ( Ignorable by Annotation )

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

45
            'code'      => /** @scrutinizer ignore-call */ kebab_case($request->name, ''),

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
46
            'is_locked' => false,
47
        ]);
48
49
        swal()->success('Setting', 'You have successfully create a earning type.');
0 ignored issues
show
Bug introduced by
The function swal 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 ignore-call  annotation

49
        /** @scrutinizer ignore-call */ 
50
        swal()->success('Setting', 'You have successfully create a earning type.');
Loading history...
50
51
        return redirect()->route('open-payroll.setting.index');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...payroll.setting.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
52
    }
53
54
    /**
55
     * Display the specified resource.
56
     *
57
     * @param int $id
58
     *
59
     * @return \Illuminate\Http\Response
60
     */
61
    public function show($id)
62
    {
63
    }
64
65
    /**
66
     * Show the form for editing the specified resource.
67
     *
68
     * @param int $id
69
     *
70
     * @return \Illuminate\Http\Response
71
     */
72
    public function edit($id)
73
    {
74
        $type = EarningType::findOrFail($id);
75
76
        return view('open-payroll.settings.earning.edit', compact('type'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('open-payrol...edit', compact('type')) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
77
    }
78
79
    /**
80
     * Update the specified resource in storage.
81
     *
82
     * @param \Illuminate\Http\Request $request
83
     * @param int                      $id
84
     *
85
     * @return \Illuminate\Http\Response
86
     */
87
    public function update(Request $request, $id)
88
    {
89
        $this->validate($request, [
90
            'name' => 'required|min:3|max:255',
91
        ]);
92
93
        EarningType::whereId($id)->update([
94
            'name'      => $request->name,
95
            'code'      => kebab_case($request->name, ''),
0 ignored issues
show
Unused Code introduced by
The call to kebab_case() has too many arguments starting with ''. ( Ignorable by Annotation )

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

95
            'code'      => /** @scrutinizer ignore-call */ kebab_case($request->name, ''),

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
96
            'is_locked' => false,
97
        ]);
98
99
        swal()->success('Setting', 'You have successfully update a earning type.');
0 ignored issues
show
Bug introduced by
The function swal 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 ignore-call  annotation

99
        /** @scrutinizer ignore-call */ 
100
        swal()->success('Setting', 'You have successfully update a earning type.');
Loading history...
100
101
        return redirect()->route('open-payroll.setting.index');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...payroll.setting.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
102
    }
103
104
    /**
105
     * Remove the specified resource from storage.
106
     *
107
     * @param int $id
108
     *
109
     * @return \Illuminate\Http\Response
110
     */
111
    public function destroy($id)
112
    {
113
        EarningType::whereId($id)->delete();
114
115
        swal()->success('Setting', 'You have successfully delete a earning type.');
0 ignored issues
show
Bug introduced by
The function swal 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 ignore-call  annotation

115
        /** @scrutinizer ignore-call */ 
116
        swal()->success('Setting', 'You have successfully delete a earning type.');
Loading history...
116
117
        return redirect()->route('open-payroll.setting.index');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route...payroll.setting.index') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
118
    }
119
}
120