Mercurial > packages > magicforger
annotate src/Generator/Controller/stubs/controller.stub @ 7:769a17898cc0
Various changes to the generators and replacers - probably mostly just formatting
| author | luka |
|---|---|
| date | Wed, 18 Oct 2023 21:04:11 -0400 |
| parents | b0b2e79ad8e6 |
| children | 3426c7e91c24 |
| 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. |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
13 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
14 public function index() |
|
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 $data = []; |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
17 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
18 $data['items'] = {{ model }}::all(); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
19 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
20 return view('{{ tableName }}.index', $data); |
|
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 |
|
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 * Show the form for creating a new resource. |
|
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 public function create() |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
27 { |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
28 $data = []; |
|
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 return view('{{ tableName }}.create_edit', $data); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
31 } |
|
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 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
34 * Store a newly created resource in storage. |
|
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 public function store({{ storeRequest }} $request) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
37 { |
| 5 | 38 $validated = $request->validated(); |
| 39 | |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
40 // |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
41 ${{ modelVariable }} = new {{ model }}(); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
42 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
43 //insert the values into the model |
|
7
769a17898cc0
Various changes to the generators and replacers - probably mostly just formatting
luka
parents:
5
diff
changeset
|
44 // {{ valuesForCreation }} |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
45 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
46 ${{ modelVariable }}->save(); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
47 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
48 return redirect()->route('{{ tableName }}.index'); |
|
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 |
|
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 * Display the specified resource. |
|
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 public function show({{ model }} ${{ modelVariable }}) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
55 { |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
56 $data = []; |
|
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 $data['item'] = ${{ modelVariable }}; |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
59 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
60 return view('{{ tableName }}.show', $data); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
61 } |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
62 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
63 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
64 * Show the form for editing the specified resource. |
|
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 public function edit({{ model }} ${{ modelVariable }}) |
|
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 $data = []; |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
69 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
70 $data['item'] = ${{ modelVariable }}; |
|
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 return view('{{ tableName }}.create_edit', $data); |
|
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 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
75 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
76 * Update the specified resource in storage. |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
77 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
78 public function update({{ updateRequest }} $request, {{ model }} ${{ modelVariable }}) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
79 { |
| 5 | 80 $validated = $request->validated(); |
| 81 | |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
82 // Set the variables |
| 5 | 83 //{{ valuesForCreation }} |
| 84 | |
|
3
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
85 ${{ modelVariable }}->save(); |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
86 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
87 return redirect()->route('{{ tableName }}.index'); |
|
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 |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
90 /** |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
91 * Remove the specified resource from storage. |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
92 */ |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
93 public function destroy({{ model }} ${{ modelVariable }}) |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
94 { |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
95 // |
|
6468684362c2
It works! Created a controller, no update insert but it works
luka
parents:
diff
changeset
|
96 ${{ modelVariable }}->delete(); |
|
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 return redirect()->route('{{ tableName }}.index'); |
|
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 } |
