This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | namespace App\Http\Controllers; |
||
4 | |||
5 | use Illuminate\Http\Request; |
||
6 | use Illuminate\Pagination\Paginator; |
||
7 | use App\Http\Controllers\Controller; |
||
8 | use App\Models\{{class_name}}; |
||
0 ignored issues
–
show
|
|||
9 | use Schema; |
||
10 | // relationship tables use classes |
||
11 | {{relationship_tables_classes}} |
||
12 | // eager use classes |
||
13 | {{eager_use_classes}} |
||
14 | |||
15 | class {{class_name}}Controller extends Controller |
||
16 | { |
||
17 | // blade views |
||
18 | // index view |
||
19 | public function index() |
||
20 | { |
||
21 | return view('{{class_name_lw}}.index'); |
||
22 | } |
||
23 | // create view |
||
24 | public function create() |
||
25 | { |
||
26 | return view('{{class_name_lw}}.create'); |
||
27 | } |
||
28 | |||
29 | // edit view |
||
30 | public function edit($id) |
||
31 | { |
||
32 | ${{class_name_lw}} = {{class_name}}::find($id); |
||
33 | |||
34 | return view('{{class_name_lw}}.edit')->with('model', ${{class_name_lw}}); |
||
35 | } |
||
36 | |||
37 | // api resources |
||
38 | |||
39 | |||
40 | // save {{class_name_lw}} |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
41 | public function store(Request $request) |
||
42 | { |
||
43 | // validate {{class_name_lw}} and eager objects |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
36% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
44 | $this->validate($request, $this->getRules()); |
||
45 | |||
46 | $model = new {{class_name}}(); |
||
47 | |||
48 | ${{class_name_lw}} = $model->store($request); |
||
49 | |||
50 | return ${{class_name_lw}}; |
||
51 | } |
||
52 | |||
53 | // update {{class_name_lw}} by id |
||
54 | public function update($id, Request $request) |
||
55 | { |
||
56 | // validate {{table_name}} and eager objects |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
36% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
57 | $this->validate($request, $this->getRules($id)); |
||
58 | |||
59 | $model = new {{class_name}}(); |
||
60 | ${{class_name_lw}} = $model->updateModel($id, $request); |
||
61 | |||
62 | return ${{class_name_lw}}; |
||
63 | } |
||
64 | |||
65 | |||
66 | // get {{class_name_lw}} by id |
||
67 | public function show($id) |
||
68 | { |
||
69 | $model = new {{class_name}}(); |
||
70 | ${{class_name_lw}} = $model->show($id); |
||
71 | return ${{class_name_lw}} ; |
||
72 | } |
||
73 | |||
74 | // find first by field and value |
||
75 | public function findByField(Request $request) |
||
76 | { |
||
77 | $model = new {{class_name}}(); |
||
78 | ${{class_name_lw}} = $model->findByField($request); |
||
79 | return ${{class_name_lw}} ; |
||
80 | } |
||
81 | |||
82 | // build all validation rules |
||
83 | protected function getRules($id = null){ |
||
84 | // default object rules |
||
85 | $model = new {{class_name}}(); |
||
86 | $rules = $model::$rules; |
||
87 | ${{class_name_lw}} = $model->show($id); |
||
88 | {{unique_rules}} |
||
89 | // nested rules for eager objects |
||
90 | {{rules_eager}} |
||
91 | |||
92 | return $rules; |
||
93 | } |
||
94 | |||
95 | // delete model by ids |
||
96 | public function destroy($id) |
||
97 | { |
||
98 | $ids = explode(",", $id); |
||
99 | $ids = array_unique($ids); |
||
100 | |||
101 | $model = new {{class_name}}(); |
||
102 | |||
103 | $success = $model->destroy($ids); |
||
104 | |||
105 | $status = array("error" => true, "message" => "Error deleting object"); |
||
106 | if ($success) |
||
107 | $status = array("error" => false, "message" => "Object successfully deleted"); |
||
108 | |||
109 | return json_encode($status); |
||
110 | |||
111 | } |
||
112 | |||
113 | {{reverseRelationships}} |
||
114 | {{relationship_tables_store}} |
||
115 | {{remove_relationship_objects}} |
||
116 | {{enum}} |
||
117 | {{checkbox}} |
||
118 | |||
119 | |||
120 | // query with search and pagination options |
||
121 | public function query(Request $request) |
||
122 | { |
||
123 | $model = new {{class_name}}(); |
||
124 | |||
125 | $query = $model->querySearch($request); |
||
126 | |||
127 | return $query; |
||
128 | } |
||
129 | |||
130 | |||
131 | // query with fields filters and pagination |
||
132 | //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
133 | public function queryFilters(Request $request) |
||
134 | { |
||
135 | $model = new {{class_name}}(); |
||
136 | |||
137 | ${{class_name_lw}} = $model->queryFilters($request); |
||
138 | |||
139 | return ${{class_name_lw}}; |
||
140 | } |
||
141 | |||
142 | |||
143 | } |
||
144 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.