Mercurial > packages > magicforger
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 24:31109c61ce02 | 25:1a717c7b211f |
|---|---|
| 15 */ | 15 */ |
| 16 public function index() | 16 public function index() |
| 17 { | 17 { |
| 18 $data = []; | 18 $data = []; |
| 19 $data['items'] = {{ model }}::all(); | 19 $data['items'] = {{ model }}::all(); |
| 20 $data['fields'] = (new {{ model }}()->getFillable()); | |
| 20 | 21 |
| 21 return view('{{ tableName }}.index', $data); | 22 return view('{{ tableName }}.index', $data); |
| 22 } | 23 } |
| 23 | 24 |
| 24 /** | 25 /** |
| 27 * @return \Illuminate\View\View | 28 * @return \Illuminate\View\View |
| 28 */ | 29 */ |
| 29 public function create() | 30 public function create() |
| 30 { | 31 { |
| 31 $data = []; | 32 $data = []; |
| 33 $data['fields'] = (new {{ model }}()->getFillable()); | |
| 32 | 34 |
| 33 return view('{{ tableName }}.create_edit', $data); | 35 return view('{{ tableName }}.create_edit', $data); |
| 34 } | 36 } |
| 35 | 37 |
| 36 /** | 38 /** |
| 56 */ | 58 */ |
| 57 public function show({{ model }} ${{ modelVariable }}) | 59 public function show({{ model }} ${{ modelVariable }}) |
| 58 { | 60 { |
| 59 $data = []; | 61 $data = []; |
| 60 $data['item'] = ${{ modelVariable }}; | 62 $data['item'] = ${{ modelVariable }}; |
| 63 $data['fields'] = (new {{ model }}()->getFillable()); | |
| 61 | 64 |
| 62 return view('{{ tableName }}.show', $data); | 65 return view('{{ tableName }}.show', $data); |
| 63 } | 66 } |
| 64 | 67 |
| 65 /** | 68 /** |
| 70 */ | 73 */ |
| 71 public function edit({{ model }} ${{ modelVariable }}) | 74 public function edit({{ model }} ${{ modelVariable }}) |
| 72 { | 75 { |
| 73 $data = []; | 76 $data = []; |
| 74 $data['item'] = ${{ modelVariable }}; | 77 $data['item'] = ${{ modelVariable }}; |
| 78 $data['fields'] = (new {{ model }}()->getFillable()); | |
| 75 | 79 |
| 76 // Load data for relationships | 80 // Load data for relationships |
| 77 | 81 |
| 78 return view('{{ tableName }}.create_edit', $data); | 82 return view('{{ tableName }}.create_edit', $data); |
| 79 } | 83 } |
