comparison 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
comparison
equal deleted inserted replaced
10:a9ff874afdbd 11:3426c7e91c24
27 } 27 }
28 28
29 return $insert; 29 return $insert;
30 } 30 }
31 31
32 protected function getAttributes()
33 {
34 $insert = '';
35 foreach ($this->get_columns() as $column) {
36 $insert .= "'".$column->getName()."' => '',\n";
37 }
38
39 return $insert;
40 }
41
42 protected function getValuesForValidation()
43 {
44 $insert = '';
45 foreach ($this->get_columns() as $column) {
46 $insert .= "'".$column->getName()."' => 'nullable',\n";
47 }
48
49 return $insert;
50 }
51
32 public function apply_inserts(string $target): string 52 public function apply_inserts(string $target): string
33 { 53 {
34 $inserts = $this->get_all_keywords($target); 54 $inserts = $this->get_all_keywords($target);
35 $available_replacements = $this->get_available_inserts(); 55 $available_replacements = $this->get_available_inserts();
36 56
46 public function get_available_inserts() 66 public function get_available_inserts()
47 { 67 {
48 $table_name = $this->getTableInput(); 68 $table_name = $this->getTableInput();
49 $replacements = [ 69 $replacements = [
50 '// {{ valuesForCreation }}' => self::getValuesForCreation(), 70 '// {{ valuesForCreation }}' => self::getValuesForCreation(),
51 ]; 71 '# {{ atributeInsertPoint }}' => self::getAttributes(),
72 '// {{ valuesForValidation }}' => self::getValuesForValidation(),
73 ];
52 74
53 foreach ($replacements as $key => &$replacement) { 75 foreach ($replacements as $key => &$replacement) {
54 $replacement = $replacement."\n".$key; 76 $replacement = $replacement."\n".$key;
55 } 77 }
56 78