1 | <?php |
||||
2 | |||||
3 | namespace App\Http\Controllers; |
||||
4 | |||||
5 | use App\Models\PersonLds; |
||||
6 | use Illuminate\Http\Request; |
||||
7 | use voku\helper\ASCII; |
||||
8 | |||||
9 | class PersonLdsController extends Controller |
||||
10 | { |
||||
11 | /** |
||||
12 | * Display a listing of the resource. |
||||
13 | * |
||||
14 | * @return \Illuminate\Http\Response |
||||
15 | */ |
||||
16 | public function index(Request $request) |
||||
17 | { |
||||
18 | $query = PersonLds::query(); |
||||
19 | |||||
20 | if ($request->has('searchTerm')) { |
||||
21 | $columnsToSearch = ['group', 'type', 'stat', 'date', 'plac', 'temp', 'slac_famc']; |
||||
22 | $search_term = json_decode($request->searchTerm)->searchTerm; |
||||
23 | if (! empty($search_term)) { |
||||
24 | $searchQuery = '%'.$search_term.'%'; |
||||
25 | foreach ($columnsToSearch as $column) { |
||||
26 | $query->orWhere($column, 'LIKE', $searchQuery); |
||||
27 | } |
||||
28 | } |
||||
29 | } |
||||
30 | |||||
31 | if ($request->has('columnFilters')) { |
||||
32 | $filters = get_object_vars(json_decode($request->columnFilters)); |
||||
33 | |||||
34 | foreach ($filters as $key => $value) { |
||||
35 | if (! empty($value)) { |
||||
36 | $query->orWhere($key, 'like', '%'.$value.'%'); |
||||
37 | } |
||||
38 | } |
||||
39 | } |
||||
40 | |||||
41 | if ($request->has('sort.0')) { |
||||
42 | $sort = json_decode($request->sort[0]); |
||||
43 | $query->orderBy($sort->field, $sort->type); |
||||
44 | } |
||||
45 | |||||
46 | if ($request->has('perPage')) { |
||||
47 | $rows = $query->paginate($request->perPage); |
||||
48 | } |
||||
49 | |||||
50 | return $rows; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||||
51 | } |
||||
52 | |||||
53 | /** |
||||
54 | * Show the form for creating a new resource. |
||||
55 | * |
||||
56 | * @return \Illuminate\Http\Response |
||||
57 | */ |
||||
58 | public function create() |
||||
59 | { |
||||
60 | // |
||||
61 | } |
||||
62 | |||||
63 | /** |
||||
64 | * Store a newly created resource in storage. |
||||
65 | * |
||||
66 | * @param \Illuminate\Http\Request $request |
||||
67 | * @return \Illuminate\Http\Response |
||||
68 | */ |
||||
69 | public function store(Request $request) |
||||
70 | { |
||||
71 | $request->validate([ |
||||
72 | 'group' => 'required', |
||||
73 | ]); |
||||
74 | |||||
75 | return PersonLds::create([ |
||||
0 ignored issues
–
show
|
|||||
76 | 'group' => $request->group, |
||||
77 | 'type' => $request->type, |
||||
78 | 'stat' => $request->stat, |
||||
79 | 'date' => $request->date, |
||||
80 | 'plac' => $request->plac, |
||||
81 | 'temp' => $request->temp, |
||||
82 | 'slac_famc' => $request->slac_famc, |
||||
83 | ]); |
||||
84 | } |
||||
85 | |||||
86 | /** |
||||
87 | * Display the specified resource. |
||||
88 | * |
||||
89 | * @param int $id |
||||
90 | * @return \Illuminate\Http\Response |
||||
91 | */ |
||||
92 | public function show($id) |
||||
93 | { |
||||
94 | return PersonLds::find($id); |
||||
0 ignored issues
–
show
|
|||||
95 | } |
||||
96 | |||||
97 | /** |
||||
98 | * Show the form for editing the specified resource. |
||||
99 | * |
||||
100 | * @param int $id |
||||
101 | * @return \Illuminate\Http\Response |
||||
102 | */ |
||||
103 | public function edit($id) |
||||
0 ignored issues
–
show
The parameter
$id 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
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
104 | { |
||||
105 | // |
||||
106 | } |
||||
107 | |||||
108 | /** |
||||
109 | * Update the specified resource in storage. |
||||
110 | * |
||||
111 | * @param \Illuminate\Http\Request $request |
||||
112 | * @param int $id |
||||
113 | * @return \Illuminate\Http\Response |
||||
114 | */ |
||||
115 | public function update(Request $request, $id) |
||||
116 | { |
||||
117 | $request->validate([ |
||||
118 | 'group' => 'required', |
||||
119 | ]); |
||||
120 | |||||
121 | $personlds = PersonLds::find($id); |
||||
122 | $personlds->group = $request->group; |
||||
123 | $personlds->type = $request->type; |
||||
124 | $personlds->date = $request->date; |
||||
125 | $personlds->plac = $request->plac; |
||||
126 | $personlds->temp = $request->temp; |
||||
127 | $personlds->slac_famc = $request->slac_famc; |
||||
128 | $personlds->save(); |
||||
129 | |||||
130 | return $personlds; |
||||
0 ignored issues
–
show
|
|||||
131 | } |
||||
132 | |||||
133 | /** |
||||
134 | * Remove the specified resource from storage. |
||||
135 | * |
||||
136 | * @param int $id |
||||
137 | * @return \Illuminate\Http\Response |
||||
138 | */ |
||||
139 | public function destroy($id) |
||||
140 | { |
||||
141 | $personlds = PersonLds::find($id); |
||||
142 | if ($personlds) { |
||||
143 | $personlds->delete(); |
||||
144 | |||||
145 | return 'true'; |
||||
0 ignored issues
–
show
|
|||||
146 | } |
||||
147 | |||||
148 | return 'false'; |
||||
0 ignored issues
–
show
|
|||||
149 | } |
||||
150 | } |
||||
151 |