Mercurial > packages > magicforger
comparison src/Generator/Controller/stubs/controller.stub @ 15:f19c023bda04 main-dev
Updated the Controller stub
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Wed, 26 Feb 2025 19:08:36 -0500 |
| parents | 3426c7e91c24 |
| children | f0b0d014e448 |
comparison
equal
deleted
inserted
replaced
| 14:c969ed13c570 | 15:f19c023bda04 |
|---|---|
| 36 public function store({{ storeRequest }} $request) | 36 public function store({{ storeRequest }} $request) |
| 37 { | 37 { |
| 38 $validated = $request->validated(); | 38 $validated = $request->validated(); |
| 39 | 39 |
| 40 // | 40 // |
| 41 ${{ modelVariable }} = new {{ model }}(); | 41 ${{ modelVariable }} = new {{ model }}($validated); |
| 42 | |
| 43 //insert the values into the model | |
| 44 ${{ modelVariable }}->map_values($validated); | |
| 45 | 42 |
| 46 ${{ modelVariable }}->save(); | 43 ${{ modelVariable }}->save(); |
| 47 | 44 |
| 48 return redirect()->route('{{ tableName }}.index'); | 45 return redirect()->route('{{ tableName }}.index'); |
| 49 } | 46 } |
| 66 public function edit({{ model }} ${{ modelVariable }}) | 63 public function edit({{ model }} ${{ modelVariable }}) |
| 67 { | 64 { |
| 68 $data = []; | 65 $data = []; |
| 69 | 66 |
| 70 $data['item'] = ${{ modelVariable }}; | 67 $data['item'] = ${{ modelVariable }}; |
| 68 | |
| 69 //load data for relationships | |
| 71 | 70 |
| 72 return view('{{ tableName }}.create_edit', $data); | 71 return view('{{ tableName }}.create_edit', $data); |
| 73 } | 72 } |
| 74 | 73 |
| 75 /** | 74 /** |
