| @@ 64-82 (lines=19) @@ | ||
| 61 | } |
|
| 62 | } |
|
| 63 | ||
| 64 | protected function getSchema() |
|
| 65 | { |
|
| 66 | $schema = $this->option('schema'); |
|
| 67 | if(! $schema){ |
|
| 68 | return $this->spaces(12) . "// Schema declaration"; |
|
| 69 | } |
|
| 70 | ||
| 71 | $items = $schema; |
|
| 72 | if( ! $this->option('parsed')){ |
|
| 73 | $items = $this->getArgumentParser('schema')->parse($schema); |
|
| 74 | } |
|
| 75 | ||
| 76 | $fields = []; |
|
| 77 | foreach ($items as $item) { |
|
| 78 | $fields[] = $this->getFieldDeclaration($item); |
|
| 79 | } |
|
| 80 | ||
| 81 | return implode(PHP_EOL, $fields); |
|
| 82 | } |
|
| 83 | ||
| 84 | protected function getAdditionals() |
|
| 85 | { |
|
| @@ 112-130 (lines=19) @@ | ||
| 109 | return " \$table" . implode('', $parts) . ';'; |
|
| 110 | } |
|
| 111 | ||
| 112 | protected function getConstraints() |
|
| 113 | { |
|
| 114 | $keys = $this->option('keys'); |
|
| 115 | if(! $keys){ |
|
| 116 | return $this->spaces(12) . "// Constraints declaration"; |
|
| 117 | } |
|
| 118 | ||
| 119 | $items = $keys; |
|
| 120 | if(! $this->option('parsed')){ |
|
| 121 | $items = $this->getArgumentParser('foreign-keys')->parse($keys); |
|
| 122 | } |
|
| 123 | ||
| 124 | $constraints = []; |
|
| 125 | foreach ($items as $item) { |
|
| 126 | $constraints[] = $this->getConstraintDeclaration($item); |
|
| 127 | } |
|
| 128 | ||
| 129 | return implode(PHP_EOL, $constraints); |
|
| 130 | } |
|
| 131 | ||
| 132 | protected function getConstraintDeclaration($key) |
|
| 133 | { |
|
| @@ 144-161 (lines=18) @@ | ||
| 141 | return $relations; |
|
| 142 | } |
|
| 143 | ||
| 144 | protected function getRules() |
|
| 145 | { |
|
| 146 | $rules = $this->option('rules'); |
|
| 147 | if(! $rules){ |
|
| 148 | return " // Validation rules"; |
|
| 149 | } |
|
| 150 | $items = $rules; |
|
| 151 | if(! $this->option('parsed')){ |
|
| 152 | $items = $this->getArgumentParser('rules')->parse($rules); |
|
| 153 | } |
|
| 154 | $rules = []; |
|
| 155 | $template = $this->getTemplate('model/rule'); |
|
| 156 | foreach ($items as $item) { |
|
| 157 | $rules[] = $template->with($item)->get(); |
|
| 158 | } |
|
| 159 | ||
| 160 | return implode(PHP_EOL, $rules); |
|
| 161 | } |
|
| 162 | ||
| 163 | protected function getAdditional() |
|
| 164 | { |
|