Mercurial > packages > magicforger
comparison src/Generator/Controller/stubs/controller.stub @ 26:555bfaa500ac codex
Big update for view creation based on the column type.
| author | Luka Sitas <sitas.luka.97@gmail.com> |
|---|---|
| date | Thu, 15 May 2025 21:50:38 -0400 |
| parents | 1a717c7b211f |
| children | b17f81b804ff |
comparison
equal
deleted
inserted
replaced
| 25:1a717c7b211f | 26:555bfaa500ac |
|---|---|
| 14 * @return \Illuminate\View\View | 14 * @return \Illuminate\View\View |
| 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 }}::get_data(); |
| 20 $data['fields'] = (new {{ model }}()->getFillable()); | 20 $data = array_merge($data, {{ model }}::load_index()); |
| 21 | 21 |
| 22 return view('{{ tableName }}.index', $data); | 22 return view('{{ tableName }}.index', $data); |
| 23 } | 23 } |
| 24 | 24 |
| 25 /** | 25 /** |
| 28 * @return \Illuminate\View\View | 28 * @return \Illuminate\View\View |
| 29 */ | 29 */ |
| 30 public function create() | 30 public function create() |
| 31 { | 31 { |
| 32 $data = []; | 32 $data = []; |
| 33 $data['fields'] = (new {{ model }}()->getFillable()); | 33 $data = array_merge($data, {{ model }}::load_create()); |
| 34 | 34 |
| 35 return view('{{ tableName }}.create_edit', $data); | 35 return view('{{ tableName }}.create_edit', $data); |
| 36 } | 36 } |
| 37 | 37 |
| 38 /** | 38 /** |
| 58 */ | 58 */ |
| 59 public function show({{ model }} ${{ modelVariable }}) | 59 public function show({{ model }} ${{ modelVariable }}) |
| 60 { | 60 { |
| 61 $data = []; | 61 $data = []; |
| 62 $data['item'] = ${{ modelVariable }}; | 62 $data['item'] = ${{ modelVariable }}; |
| 63 $data['fields'] = (new {{ model }}()->getFillable()); | 63 $data['fields'] = (new {{ model }}())->getFillable(); |
| 64 | 64 |
| 65 return view('{{ tableName }}.show', $data); | 65 return view('{{ tableName }}.show', $data); |
| 66 } | 66 } |
| 67 | 67 |
| 68 /** | 68 /** |
| 73 */ | 73 */ |
| 74 public function edit({{ model }} ${{ modelVariable }}) | 74 public function edit({{ model }} ${{ modelVariable }}) |
| 75 { | 75 { |
| 76 $data = []; | 76 $data = []; |
| 77 $data['item'] = ${{ modelVariable }}; | 77 $data['item'] = ${{ modelVariable }}; |
| 78 $data['fields'] = (new {{ model }}()->getFillable()); | |
| 79 | 78 |
| 80 // Load data for relationships | 79 // Load data for relationships |
| 80 $data = array_merge($data, {{ model }}::load_edit()); | |
| 81 | 81 |
| 82 return view('{{ tableName }}.create_edit', $data); | 82 return view('{{ tableName }}.create_edit', $data); |
| 83 } | 83 } |
| 84 | 84 |
| 85 /** | 85 /** |
