changeset 44:cde7e0f145fa ls_dev_2025_09

merge heads
author Luka Sitas <sitas.luka.97@gmail.com>
date Thu, 12 Nov 2026 21:19:35 -0500
parents 50ca202284d5 (current diff) 62953a663acc (diff)
children c7fd31303024
files
diffstat 5 files changed, 46 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/Generator/Controller/stubs/controller.stub	Thu Nov 12 21:19:22 2026 -0500
+++ b/src/Generator/Controller/stubs/controller.stub	Thu Nov 12 21:19:35 2026 -0500
@@ -16,20 +16,19 @@
      */
     public function index({{ filterRequest }} $request)
     {
-				$validated = $request->validated();
+		$validated = $request->validated();
         $data = [];
-        $data['items'] = {{ model }}::get_data($validated);
-				$data = array_merge($data, {{ model }}::load_index());
+		$data = array_merge($data, {{ model }}::load_index());
 
         return view('{{ tableName }}.index', $data);
     }
 
-    public function get_data()
+    public function get_data({{ filterRequest }} $request)
     {
+        $validated = $request->validated() ?? [];
         $data = [];
-        $data['records'] = {{ model }}::get_data([]);
-        $data['total_records'] = count($data['records']);
 
+        $data = array_merge($data, {{ model }}::get_data($validated));
         return $data;
     }
 
--- a/src/Generator/Factory/FactoryGenerator.php	Thu Nov 12 21:19:22 2026 -0500
+++ b/src/Generator/Factory/FactoryGenerator.php	Thu Nov 12 21:19:35 2026 -0500
@@ -119,11 +119,11 @@
 
         switch ($column['type_name']) {
             case 'date':
-                return "$value$nullable->date()";
+                return "$value${nullable}->date()";
             case 'timestamp':
-                return "$value$nullable->timestamp()";
+                return "$value${nullable}->timestamp()";
             case 'tinyint':
-                return "$value$nullable->numberBetween(0,1)";
+                return "$value${nullable}->numberBetween(0,1)";
             case 'bigint':
                 if (isset($relations['belongsTo'][$column['name']])) {
                     $related = $this->getNamespacedModel($relations['belongsTo'][$column['name']]['table']);
@@ -131,11 +131,11 @@
                 }
                 // fall through to int for lack of better option
             case 'int':
-                return "$value$nullable->randomNumber()";
+                return "$value${nullable}->randomNumber()";
             case 'float':
-                return "$value$nullable->randomFloat()";
+                return "$value${nullable}->randomFloat()";
             default:
-                return "$value$nullable->text()";
+                return "$value${nullable}->text()";
         }
     }
 
--- a/src/Generator/Requests/FilterRequestGenerator.php	Thu Nov 12 21:19:22 2026 -0500
+++ b/src/Generator/Requests/FilterRequestGenerator.php	Thu Nov 12 21:19:35 2026 -0500
@@ -44,7 +44,7 @@
      */
     protected function getStub()
     {
-        return $this->resolveStubPath('/stubs/request.stub');
+        return $this->resolveStubPath('/stubs/filter_request.stub');
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Generator/Requests/stubs/filter_request.stub	Thu Nov 12 21:19:35 2026 -0500
@@ -0,0 +1,33 @@
+<?php
+
+namespace {{ namespace }};
+
+use Illuminate\Foundation\Http\FormRequest;
+
+class {{ class }} extends FormRequest
+{
+    /**
+     * Determine if the user is authorized to make this request.
+     */
+    public function authorize(): bool
+    {
+        return true;
+    }
+
+    /**
+     * Get the validation rules that apply to the request.
+     *
+     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
+     */
+    public function rules(): array
+    {
+        return [
+            'filters' => [
+                // {{ valuesForValidation }} 
+            ],
+            'page' => ['nullable', 'int', 'min:0'],
+            'page_size' => ['nullable', 'int', 'min:0'],
+            'sort' => ['nullable', 'array'],
+        ];
+    }
+}
--- a/src/Generator/View/stubs/index.stub	Thu Nov 12 21:19:22 2026 -0500
+++ b/src/Generator/View/stubs/index.stub	Thu Nov 12 21:19:35 2026 -0500
@@ -28,6 +28,7 @@
             if (el) {
                 new ServerTable(el, {
                     endpoint: '/{{ tableName }}/get_data',
+                    filters: Object.fromEntries(new URLSearchParams(location.search)),
                     columns: [
             	        {{ columnInsertPoint }}
                         {