@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function handle() |
| 23 | 23 | { |
| 24 | - if(!$this->option()){ |
|
| 24 | + if (!$this->option()) { |
|
| 25 | 25 | $this->info("model option must have a value"); |
| 26 | 26 | return; |
| 27 | 27 | } |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $path = resource_path("cruds/{$name}.php"); |
| 35 | 35 | |
| 36 | - if (! $this->files->isDirectory(dirname($path))) { |
|
| 36 | + if (!$this->files->isDirectory(dirname($path))) { |
|
| 37 | 37 | $this->files->makeDirectory(dirname($path), 0755, true); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if($this->files->exists($path) and !$this->option('force')){ |
|
| 40 | + if ($this->files->exists($path) and !$this->option('force')) { |
|
| 41 | 41 | $this->warn("'{$name}' exists in CRUDs config"); |
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if($name != strtolower($this->option('model'))){ |
|
| 45 | + if ($name != strtolower($this->option('model'))) { |
|
| 46 | 46 | $this->warn("'{$name}' must be equal to model name"); |
| 47 | 47 | return; |
| 48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $model = $this->qualifyModel($this->option('model')); |
| 57 | 57 | |
| 58 | - if(!class_exists($model)){ |
|
| 58 | + if (!class_exists($model)) { |
|
| 59 | 59 | $this->warn("Model option should be valid and model should be exist"); |
| 60 | 60 | die(); |
| 61 | 61 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | return str_replace(array_keys($array), array_values($array), $stub); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function parseBlade($stub){ |
|
| 41 | + public function parseBlade($stub) { |
|
| 42 | 42 | $modelNamespace = $this->parseModel($this->getConfig('model')); |
| 43 | 43 | $modelName = $this->getModelName($modelNamespace); |
| 44 | 44 | $array = [ |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | return $this->qualifyModel($model); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function getConfig($key, $action = null){ |
|
| 64 | + public function getConfig($key, $action = null) { |
|
| 65 | 65 | $action = $action ?? $this->getNameInput(); |
| 66 | 66 | |
| 67 | - if(config('easy_panel.crud.'.$action.'.'.$key)){ |
|
| 67 | + if (config('easy_panel.crud.'.$action.'.'.$key)) { |
|
| 68 | 68 | return config('easy_panel.crud.'.$action.'.'.$key); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -117,18 +117,18 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $str = ''; |
| 119 | 119 | foreach ($fields as $key => $field) { |
| 120 | - $str .= $field != end($fields) ? "'$key' => " . '$this' . "->$key,".$this->makeTab(3) : "'$key' => " . '$this' . "->$key,"; |
|
| 120 | + $str .= $field != end($fields) ? "'$key' => ".'$this'."->$key,".$this->makeTab(3) : "'$key' => ".'$this'."->$key,"; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $model = $this->getNameInput(); |
| 124 | - if(config("easy_panel.crud.$model.extra_values")){ |
|
| 124 | + if (config("easy_panel.crud.$model.extra_values")) { |
|
| 125 | 125 | $str .= $this->parseExtraValues(); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | return $str; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public function parseExtraValues(){ |
|
| 131 | + public function parseExtraValues() { |
|
| 132 | 132 | $str = ''; |
| 133 | 133 | |
| 134 | 134 | $values = $this->getConfig('extra_values'); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $str .= '<div class="form-group">'.$this->makeTab(4); |
| 173 | 173 | $str .= '<label for="input'.$key.'" class="col-sm-2 control-label">'.ucfirst($key).'</label>'.$this->makeTab(4); |
| 174 | 174 | $str = $this->inputsHTML($type, $key, $str).$this->makeTab(4); |
| 175 | - $str .='@error("'.$key.'") <div class="invalid-feedback">{{ $message }}</div> @enderror'.$this->makeTab(3); |
|
| 175 | + $str .= '@error("'.$key.'") <div class="invalid-feedback">{{ $message }}</div> @enderror'.$this->makeTab(3); |
|
| 176 | 176 | $str .= '</div>'.$this->makeTab(3); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -182,19 +182,19 @@ discard block |
||
| 182 | 182 | public function inputsHTML($type, $key, string $str): string |
| 183 | 183 | { |
| 184 | 184 | $array = [ |
| 185 | - 'text' => '<input type="text" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 186 | - 'email' => '<input type="email" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 187 | - 'number' => '<input type="number" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 188 | - 'file' => '<input type="file" wire:model="' . $key . '" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input' . $key . '">', |
|
| 189 | - 'textarea' => '<textarea wire:model="' . $key . '" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
| 190 | - 'password' => '<input type="password" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 185 | + 'text' => '<input type="text" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 186 | + 'email' => '<input type="email" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 187 | + 'number' => '<input type="number" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 188 | + 'file' => '<input type="file" wire:model="'.$key.'" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input'.$key.'">', |
|
| 189 | + 'textarea' => '<textarea wire:model="'.$key.'" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
| 190 | + 'password' => '<input type="password" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 191 | 191 | ]; |
| 192 | 192 | $str .= $array[$type]; |
| 193 | 193 | |
| 194 | 194 | return $str; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - public function makeTab($count, $newLine = true){ |
|
| 197 | + public function makeTab($count, $newLine = true) { |
|
| 198 | 198 | $count = $count * 4; |
| 199 | 199 | $tabs = str_repeat(' ', $count); |
| 200 | 200 | |