LinkTypeController   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 30
c 0
b 0
f 0
dl 0
loc 119
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A destroy() 0 9 1
A store() 0 19 1
A create() 0 3 1
A show() 0 2 1
A index() 0 8 1
A edit() 0 5 1
A update() 0 17 1
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use App\Http\Controllers\Controller;
6
use App\Models\LinkType;
7
use Illuminate\Http\Request;
8
use \App\Http\Requests\LinkTypeRequest;
0 ignored issues
show
Bug introduced by
The type \App\Http\Requests\LinkTypeRequest 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...
9
10
class LinkTypeController extends Controller
11
{
12
    /**
13
     * Display a listing of the resource.
14
     *
15
     * @return \Illuminate\Http\Response
16
     */
17
    public function index()
18
    {
19
        // get all the sharks
20
        $LinkTypes = LinkType::all();
21
22
        // load the view and pass the link types
23
        return View('panel.linktype.index')
0 ignored issues
show
Bug Best Practice introduced by
The expression return View('panel.linkt...'linktype', $LinkTypes) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
24
            ->with('linktype', $LinkTypes);
25
    }
26
27
    /**
28
     * Show the form for creating a new resource.
29
     *
30
     * @return \Illuminate\Http\Response
31
     */
32
    public function create()
33
    {
34
        return View('panel.linktype.create');
0 ignored issues
show
Bug Best Practice introduced by
The expression return View('panel.linktype.create') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
35
    }
36
37
    /**
38
     * Store a newly created resource in storage.
39
     *
40
     * @param  \Illuminate\Http\Request  $request
41
     * @return \Illuminate\Http\Response
42
     */
43
    public function store(LinkTypeRequest $request)
44
    {
45
        // validate
46
        // read more on validation at http://laravel.com/docs/validation
47
48
        $validated = $request->validated();
0 ignored issues
show
Unused Code introduced by
The assignment to $validated is dead and can be removed.
Loading history...
49
50
        // store
51
        $LinkType = new LinkType;
52
        $LinkType->typename       = $request->typename;
0 ignored issues
show
Bug introduced by
The property typename does not seem to exist on App\Models\LinkType. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
53
        $LinkType->title      = $request->title;
0 ignored issues
show
Bug introduced by
The property title does not seem to exist on App\Models\LinkType. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
54
        $LinkType->description = $request->description;
0 ignored issues
show
Bug introduced by
The property description does not seem to exist on App\Models\LinkType. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
55
        $LinkType->icon            = $request->icon;
0 ignored issues
show
Bug introduced by
The property icon does not seem to exist on App\Models\LinkType. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
56
        $LinkType->params = $request->params;
0 ignored issues
show
Bug introduced by
The property params does not seem to exist on App\Models\LinkType. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
57
        $LinkType->save();
58
59
        // redirect
60
        return Redirect('admin/linktype')
0 ignored issues
show
Bug Best Practice introduced by
The expression return Redirect('admin/l... type has been added.') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
61
            ->with('success', 'New link type has been added.');
62
    }
63
64
    /**
65
     * Display the specified resource.
66
     *
67
     * @param  \App\Models\LinkType  $linkType
68
     * @return \Illuminate\Http\Response
69
     */
70
    public function show(LinkType $linkType)
0 ignored issues
show
Unused Code introduced by
The parameter $linkType 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

70
    public function show(/** @scrutinizer ignore-unused */ LinkType $linkType)

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...
71
    {
72
        //
73
    }
74
75
    /**
76
     * Show the form for editing the specified resource.
77
     *
78
     * @param  \App\Models\LinkType  $linkType
79
     * @return \Illuminate\Http\Response
80
     */
81
    public function edit($id)
82
    {
83
        $lt = LinkType::find($id);
84
        // show the edit form and pass the shark
85
        return View('panel.linktype.edit', ['linktype' => $lt]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return View('panel.linkt...ray('linktype' => $lt)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
86
    }
87
88
    /**
89
     * Update the specified resource in storage.
90
     *
91
     * @param  \Illuminate\Http\Request  $request
92
     * @param  \App\Models\LinkType  $linkType
93
     * @return \Illuminate\Http\Response
94
     */
95
    public function update(LinkTypeRequest $request, $id)
96
    {
97
        $linktype = LinkType::find($id);
98
99
        $validated = $request->validated();
0 ignored issues
show
Unused Code introduced by
The assignment to $validated is dead and can be removed.
Loading history...
100
101
102
        // store
103
        $linktype->title      = $request->title;
104
        $linktype->description = $request->description;
105
        $linktype->icon            = $request->icon;
106
        $linktype->params = $request->params;
107
        $linktype->save();
108
109
        // redirect
110
        return Redirect('admin/linktype')
0 ignored issues
show
Bug Best Practice introduced by
The expression return Redirect('admin/l..., 'Link type updated.') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
111
            ->with('success', 'Link type updated.');
112
    }
113
114
    /**
115
     * Remove the specified resource from storage.
116
     *
117
     * @param  \App\Models\LinkType  $linkType
118
     * @return \Illuminate\Http\Response
119
     */
120
    public function destroy($id)
121
    {
122
        // delete
123
        $linktype = LinkType::find($id);
124
        $linktype->delete();
125
126
        // redirect
127
        return Redirect('admin/linktype')
0 ignored issues
show
Bug Best Practice introduced by
The expression return Redirect('admin/l...', 'Link type deleted') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
128
            ->with('success', 'Link type deleted');
129
    }
130
}
131