Mercurial > packages > magicforger
annotate src/Generator/Controller/stubs/controller.stub @ 25:1a717c7b211f codex
added support for some basic views
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Sun, 11 May 2025 21:03:51 -0400 |
| parents | 827efbf4d73c |
| children | 555bfaa500ac |
| 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(); |
|
25
1a717c7b211f
added support for some basic views
Luka Sitas <sitas.luka.97@gmail.com>
parents:
23
diff
changeset
|
20 $data['fields'] = (new {{ model }}()->getFillable()); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
21 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
22 return view('{{ tableName }}.index', $data); |
|
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 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
26 * 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
|
27 * |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
28 * @return \Illuminate\View\View |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
29 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
30 public function create() |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
31 { |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
32 $data = []; |
|
25
1a717c7b211f
added support for some basic views
Luka Sitas <sitas.luka.97@gmail.com>
parents:
23
diff
changeset
|
33 $data['fields'] = (new {{ model }}()->getFillable()); |
|
3
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 return view('{{ tableName }}.create_edit', $data); |
|
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 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
38 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
39 * 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
|
40 * |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
41 * @param {{ storeRequest }} $request |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
42 * @return \Illuminate\Http\RedirectResponse |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
43 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
44 public function store({{ storeRequest }} $request) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
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 $validated = $request->validated(); |
| 5 | 47 |
|
23
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
21
diff
changeset
|
48 {{ model }}::create($validated); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
49 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
50 return redirect()->route('{{ tableName }}.index'); |
|
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 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
54 * 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
|
55 * |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
56 * @param {{ model }} ${{ modelVariable }} |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
57 * @return \Illuminate\View\View |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
58 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
59 public function show({{ model }} ${{ modelVariable }}) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
60 { |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
61 $data = []; |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
62 $data['item'] = ${{ modelVariable }}; |
|
25
1a717c7b211f
added support for some basic views
Luka Sitas <sitas.luka.97@gmail.com>
parents:
23
diff
changeset
|
63 $data['fields'] = (new {{ model }}()->getFillable()); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
64 |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
65 return view('{{ tableName }}.show', $data); |
|
3
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 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
68 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
69 * 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
|
70 * |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
71 * @param {{ model }} ${{ modelVariable }} |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
72 * @return \Illuminate\View\View |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
73 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
74 public function edit({{ model }} ${{ modelVariable }}) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
75 { |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
76 $data = []; |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
77 $data['item'] = ${{ modelVariable }}; |
|
25
1a717c7b211f
added support for some basic views
Luka Sitas <sitas.luka.97@gmail.com>
parents:
23
diff
changeset
|
78 $data['fields'] = (new {{ model }}()->getFillable()); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
79 |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
80 // Load data for relationships |
|
15
f19c023bda04
Updated the Controller stub
Luka Sitas <sitas.luka.97@gmail.com>
parents:
11
diff
changeset
|
81 |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
82 return view('{{ tableName }}.create_edit', $data); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
83 } |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
84 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
85 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
86 * 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
|
87 * |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
88 * @param {{ updateRequest }} $request |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
89 * @param {{ model }} ${{ modelVariable }} |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
90 * @return \Illuminate\Http\RedirectResponse |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
91 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
92 public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }}) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
93 { |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
94 $validated = $request->validated(); |
| 5 | 95 |
|
23
827efbf4d73c
Huge changes to the relationships for models and more complex
Luka Sitas <sitas.luka.97@gmail.com>
parents:
21
diff
changeset
|
96 ${{ modelVariable }}->update($validated); |
| 5 | 97 |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
98 return redirect()->route('{{ tableName }}.index'); |
|
3
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 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
101 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
102 * 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
|
103 * |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
104 * @param {{ model }} ${{ modelVariable }} |
|
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
105 * @return \Illuminate\Http\RedirectResponse |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
106 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
107 public function destroy({{ model }} ${{ modelVariable }}) |
|
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 ${{ modelVariable }}->delete(); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
110 |
|
21
f0b0d014e448
Cleaning up code based on AI overlord review
Luka Sitas <sitas.luka.97@gmail.com>
parents:
15
diff
changeset
|
111 return redirect()->route('{{ tableName }}.index'); |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
112 } |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
113 } |
