diff src/Replacer/TableReplacer.php @ 11:3426c7e91c24 main-dev

Modifying generaters and replacers
author luka
date Wed, 24 Apr 2024 19:53:42 -0400
parents 769a17898cc0
children c969ed13c570
line wrap: on
line diff
--- a/src/Replacer/TableReplacer.php	Sat Dec 02 10:20:32 2023 -0500
+++ b/src/Replacer/TableReplacer.php	Wed Apr 24 19:53:42 2024 -0400
@@ -29,6 +29,26 @@
         return $insert;
     }
 
+    protected function getAttributes()
+    {
+        $insert = '';
+        foreach ($this->get_columns() as $column) {
+            $insert .= "'".$column->getName()."' => '',\n";
+        }
+
+        return $insert;
+    }
+
+    protected function getValuesForValidation()
+    {
+        $insert = '';
+        foreach ($this->get_columns() as $column) {
+            $insert .= "'".$column->getName()."' => 'nullable',\n";
+        }
+
+        return $insert;
+    }
+
     public function apply_inserts(string $target): string
     {
         $inserts = $this->get_all_keywords($target);
@@ -48,7 +68,9 @@
         $table_name = $this->getTableInput();
         $replacements = [
                         '// {{ valuesForCreation }}' => self::getValuesForCreation(),
-        ];
+                        '# {{ atributeInsertPoint }}' => self::getAttributes(),
+            						'// {{ valuesForValidation }}' => self::getValuesForValidation(),
+			        ];
 
         foreach ($replacements as $key => &$replacement) {
             $replacement = $replacement."\n".$key;