diff 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
line wrap: on
line diff
--- a/src/Generator/Controller/stubs/controller.stub	Sun May 11 21:03:51 2025 -0400
+++ b/src/Generator/Controller/stubs/controller.stub	Thu May 15 21:50:38 2025 -0400
@@ -16,8 +16,8 @@
     public function index()
     {
         $data = [];
-        $data['items'] = {{ model }}::all();
-				$data['fields'] = (new {{ model }}()->getFillable());
+        $data['items'] = {{ model }}::get_data();
+				$data = array_merge($data, {{ model }}::load_index());
 
         return view('{{ tableName }}.index', $data);
     }
@@ -30,7 +30,7 @@
     public function create()
     {
         $data = [];
-				$data['fields'] = (new {{ model }}()->getFillable());
+				$data = array_merge($data, {{ model }}::load_create());
 
         return view('{{ tableName }}.create_edit', $data);
     }
@@ -60,7 +60,7 @@
     {
         $data = [];
         $data['item'] = ${{ modelVariable }};
-				$data['fields'] = (new {{ model }}()->getFillable());
+				$data['fields'] = (new {{ model }}())->getFillable();
 
         return view('{{ tableName }}.show', $data);
     }
@@ -75,9 +75,9 @@
     {
         $data = [];
         $data['item'] = ${{ modelVariable }};
-				$data['fields'] = (new {{ model }}()->getFillable());
 
         // Load data for relationships
+				$data = array_merge($data, {{ model }}::load_edit());
 
         return view('{{ tableName }}.create_edit', $data);
     }