annotate src/Generator/Controller/stubs/controller.stub @ 21:f0b0d014e448 main-dev

Cleaning up code based on AI overlord review
author Luka Sitas <sitas.luka.97@gmail.com>
date Wed, 26 Feb 2025 19:45:08 -0500
parents f19c023bda04
children 827efbf4d73c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
1 <?php
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
2
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
3 namespace {{ namespace }};
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
4
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
5 use {{ namespacedModel }};
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
6 use {{ rootNamespace }}Http\Controllers\Controller;
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
7 {{ requestUses }}
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
8
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
9 class {{ class }} extends Controller
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
10 {
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
11 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
12 * Display a listing of the resource.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
13 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
14 * @return \Illuminate\View\View
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
15 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
16 public function index()
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
17 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
18 $data = [];
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
19 $data['items'] = {{ model }}::all();
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
20
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
21 return view('{{ tableName }}.index', $data);
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
22 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
23
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
24 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
25 * Show the form for creating a new resource.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
26 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
27 * @return \Illuminate\View\View
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
28 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
29 public function create()
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
30 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
31 $data = [];
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
32
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
33 return view('{{ tableName }}.create_edit', $data);
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
34 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
35
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
36 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
37 * Store a newly created resource in storage.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
38 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
39 * @param {{ storeRequest }} $request
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
40 * @return \Illuminate\Http\RedirectResponse
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
41 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
42 public function store({{ storeRequest }} $request)
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
43 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
44 $validated = $request->validated();
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 3
diff changeset
45
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
46 ${{ modelVariable }} = new {{ model }}($validated);
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
47 ${{ modelVariable }}->save();
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
48
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
49 return redirect()->route('{{ tableName }}.index');
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
50 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
51
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
52 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
53 * Display the specified resource.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
54 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
55 * @param {{ model }} ${{ modelVariable }}
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
56 * @return \Illuminate\View\View
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
57 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
58 public function show({{ model }} ${{ modelVariable }})
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
59 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
60 $data = [];
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
61 $data['item'] = ${{ modelVariable }};
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
62
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
63 return view('{{ tableName }}.show', $data);
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
64 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
65
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
66 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
67 * Show the form for editing the specified resource.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
68 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
69 * @param {{ model }} ${{ modelVariable }}
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
70 * @return \Illuminate\View\View
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
71 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
72 public function edit({{ model }} ${{ modelVariable }})
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
73 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
74 $data = [];
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
75 $data['item'] = ${{ modelVariable }};
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
76
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
77 // Load data for relationships
15
f19c023bda04 Updated the Controller stub
Luka Sitas <sitas.luka.97@gmail.com>
parents: 11
diff changeset
78
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
79 return view('{{ tableName }}.create_edit', $data);
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
80 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
81
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
82 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
83 * Update the specified resource in storage.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
84 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
85 * @param {{ updateRequest }} $request
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
86 * @param {{ model }} ${{ modelVariable }}
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
87 * @return \Illuminate\Http\RedirectResponse
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
88 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
89 public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }})
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
90 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
91 $validated = $request->validated();
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 3
diff changeset
92
11
3426c7e91c24 Modifying generaters and replacers
luka
parents: 7
diff changeset
93 ${{ modelVariable }}->map_values($validated);
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
94 ${{ modelVariable }}->save();
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents: 3
diff changeset
95
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
96 return redirect()->route('{{ tableName }}.index');
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
97 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
98
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
99 /**
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
100 * Remove the specified resource from storage.
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
101 *
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
102 * @param {{ model }} ${{ modelVariable }}
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
103 * @return \Illuminate\Http\RedirectResponse
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
104 */
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
105 public function destroy({{ model }} ${{ modelVariable }})
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
106 {
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
107 ${{ modelVariable }}->delete();
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
108
21
f0b0d014e448 Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents: 15
diff changeset
109 return redirect()->route('{{ tableName }}.index');
3
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
110 }
6468684362c2 It works! Created a controller, no update insert but it works
luka
parents:
diff changeset
111 }