|
@@ -39,7 +39,7 @@ discard block |
|
|
block discarded – undo |
|
39
|
39
|
return str_replace(array_keys($array), array_values($array), $stub); |
|
40
|
40
|
} |
|
41
|
41
|
|
|
42
|
|
- public function parseBlade($stub){ |
|
|
42
|
+ public function parseBlade($stub) { |
|
43
|
43
|
$modelNamespace = $this->parseModel($this->getConfig('model')); |
|
44
|
44
|
$modelName = $this->getModelName($modelNamespace); |
|
45
|
45
|
$array = [ |
|
@@ -62,10 +62,10 @@ discard block |
|
|
block discarded – undo |
|
62
|
62
|
return $this->qualifyModel($model); |
|
63
|
63
|
} |
|
64
|
64
|
|
|
65
|
|
- public function getConfig($key, $action = null){ |
|
|
65
|
+ public function getConfig($key, $action = null) { |
|
66
|
66
|
$action = $action ?? $this->getNameInput(); |
|
67
|
67
|
|
|
68
|
|
- if(config('easy_panel.crud.'.$action.'.'.$key)){ |
|
|
68
|
+ if (config('easy_panel.crud.'.$action.'.'.$key)) { |
|
69
|
69
|
return config('easy_panel.crud.'.$action.'.'.$key); |
|
70
|
70
|
} |
|
71
|
71
|
|
|
@@ -118,18 +118,18 @@ discard block |
|
|
block discarded – undo |
|
118
|
118
|
{ |
|
119
|
119
|
$str = ''; |
|
120
|
120
|
foreach ($fields as $key => $field) { |
|
121
|
|
- $str .= $field != end($fields) ? "'$key' => " . '$this' . "->$key,".$this->makeTab(3) : "'$key' => " . '$this' . "->$key,"; |
|
|
121
|
+ $str .= $field != end($fields) ? "'$key' => ".'$this'."->$key,".$this->makeTab(3) : "'$key' => ".'$this'."->$key,"; |
|
122
|
122
|
} |
|
123
|
123
|
|
|
124
|
124
|
$model = $this->getNameInput(); |
|
125
|
|
- if(config("easy_panel.crud.$model.extra_values")){ |
|
|
125
|
+ if (config("easy_panel.crud.$model.extra_values")) { |
|
126
|
126
|
$str .= $this->parseExtraValues(); |
|
127
|
127
|
} |
|
128
|
128
|
|
|
129
|
129
|
return $str; |
|
130
|
130
|
} |
|
131
|
131
|
|
|
132
|
|
- public function parseExtraValues(){ |
|
|
132
|
+ public function parseExtraValues() { |
|
133
|
133
|
$str = ''; |
|
134
|
134
|
|
|
135
|
135
|
$values = $this->getConfig('extra_values'); |
|
@@ -147,10 +147,10 @@ discard block |
|
|
block discarded – undo |
|
147
|
147
|
$modelName = strtolower($modelName); |
|
148
|
148
|
foreach ($fields as $value) { |
|
149
|
149
|
if (!is_array($value)) { |
|
150
|
|
- $str .= '<td> {{ $' . $modelName . '->' . $value . " }} </td>" . $this->makeTab(1, end($fields) != $value); |
|
|
150
|
+ $str .= '<td> {{ $'.$modelName.'->'.$value." }} </td>".$this->makeTab(1, end($fields) != $value); |
|
151
|
151
|
} else { |
|
152
|
152
|
$relationName = array_key_first($value); |
|
153
|
|
- $str .= '<td> {{ $' . $modelName . '->' . $relationName . '->'. $value[array_key_first($value)] .' }} </td>' . $this->makeTab(1, end($fields) != $value); |
|
|
153
|
+ $str .= '<td> {{ $'.$modelName.'->'.$relationName.'->'.$value[array_key_first($value)].' }} </td>'.$this->makeTab(1, end($fields) != $value); |
|
154
|
154
|
} |
|
155
|
155
|
} |
|
156
|
156
|
|
|
@@ -166,7 +166,7 @@ discard block |
|
|
block discarded – undo |
|
166
|
166
|
$field = ucfirst($field); |
|
167
|
167
|
} else { |
|
168
|
168
|
$relationName = array_key_first($field); |
|
169
|
|
- $field = ucfirst($relationName). ' ' . ucfirst($field[array_key_first($field)]); |
|
|
169
|
+ $field = ucfirst($relationName).' '.ucfirst($field[array_key_first($field)]); |
|
170
|
170
|
} |
|
171
|
171
|
$str .= "<td> $field </td>".$this->makeTab(6, end($fields) != $field); |
|
172
|
172
|
} |
|
@@ -183,7 +183,7 @@ discard block |
|
|
block discarded – undo |
|
183
|
183
|
$str .= '<div class="form-group">'.$this->makeTab(4); |
|
184
|
184
|
$str .= '<label for="input'.$key.'" class="col-sm-2 control-label">'.ucfirst($key).'</label>'.$this->makeTab(4); |
|
185
|
185
|
$str = $this->inputsHTML($type, $key, $str).$this->makeTab(4); |
|
186
|
|
- $str .='@error("'.$key.'") <div class="invalid-feedback">{{ $message }}</div> @enderror'.$this->makeTab(3); |
|
|
186
|
+ $str .= '@error("'.$key.'") <div class="invalid-feedback">{{ $message }}</div> @enderror'.$this->makeTab(3); |
|
187
|
187
|
$str .= '</div>'.$this->makeTab(3); |
|
188
|
188
|
} |
|
189
|
189
|
|
|
@@ -193,28 +193,28 @@ discard block |
|
|
block discarded – undo |
|
193
|
193
|
public function inputsHTML($type, $key, string $str): string |
|
194
|
194
|
{ |
|
195
|
195
|
$array = [ |
|
196
|
|
- 'text' => '<input type="text" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
197
|
|
- 'email' => '<input type="email" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
198
|
|
- 'number' => '<input type="number" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
199
|
|
- 'file' => '<input type="file" wire:model="' . $key . '" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input' . $key . '">', |
|
200
|
|
- 'textarea' => '<textarea wire:model="' . $key . '" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
201
|
|
- 'password' => '<input type="password" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
|
196
|
+ 'text' => '<input type="text" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
|
197
|
+ 'email' => '<input type="email" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
|
198
|
+ 'number' => '<input type="number" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
|
199
|
+ 'file' => '<input type="file" wire:model="'.$key.'" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input'.$key.'">', |
|
|
200
|
+ 'textarea' => '<textarea wire:model="'.$key.'" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
|
201
|
+ 'password' => '<input type="password" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
202
|
202
|
]; |
|
203
|
203
|
$str .= $array[$type]; |
|
204
|
204
|
|
|
205
|
205
|
return $str; |
|
206
|
206
|
} |
|
207
|
207
|
|
|
208
|
|
- public function makeTab($count, $newLine = true){ |
|
|
208
|
+ public function makeTab($count, $newLine = true) { |
|
209
|
209
|
$count = $count * 4; |
|
210
|
210
|
$tabs = str_repeat(' ', $count); |
|
211
|
211
|
|
|
212
|
212
|
return $newLine ? "\n".$tabs : $tabs; |
|
213
|
213
|
} |
|
214
|
214
|
|
|
215
|
|
- public function parseRelationName($column){ |
|
|
215
|
+ public function parseRelationName($column) { |
|
216
|
216
|
$relations = $this->getConfig('relations'); |
|
217
|
|
- if(array_key_exists($column, $relations)){ |
|
|
217
|
+ if (array_key_exists($column, $relations)) { |
|
218
|
218
|
return $relations[$column]; |
|
219
|
219
|
} |
|
220
|
220
|
|