@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return str_replace(array_keys($array), array_values($array), $stub); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function parseBlade($stub){ |
|
| 39 | + public function parseBlade($stub) { |
|
| 40 | 40 | $modelNamespace = $this->parseModel($this->getConfig('model')); |
| 41 | 41 | $modelName = $this->getModelName($modelNamespace); |
| 42 | 42 | $array = [ |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | return $this->qualifyModel($model); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function getConfig($key, $action = null){ |
|
| 62 | + public function getConfig($key, $action = null) { |
|
| 63 | 63 | $action = $action ?? $this->getNameInput(); |
| 64 | 64 | |
| 65 | 65 | return config("easy_panel.crud.$action.$key") ?: []; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $fields = array_keys($fields); |
| 78 | 78 | $str = ''; |
| 79 | 79 | |
| 80 | - if(in_array($this->getNameInput(), $fields)){ |
|
| 80 | + if (in_array($this->getNameInput(), $fields)) { |
|
| 81 | 81 | $this->error("Model name must not equal to column names, fix it and rerun command with -f flag"); |
| 82 | 82 | die; |
| 83 | 83 | } |
@@ -131,18 +131,18 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $str = ''; |
| 133 | 133 | foreach ($fields as $key => $field) { |
| 134 | - $str .= $field != end($fields) ? "'$key' => " . '$this' . "->$key,".$this->makeTab(3) : "'$key' => " . '$this' . "->$key,"; |
|
| 134 | + $str .= $field != end($fields) ? "'$key' => ".'$this'."->$key,".$this->makeTab(3) : "'$key' => ".'$this'."->$key,"; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $model = $this->getNameInput(); |
| 138 | - if(config("easy_panel.crud.$model.extra_values")){ |
|
| 138 | + if (config("easy_panel.crud.$model.extra_values")) { |
|
| 139 | 139 | $str .= $this->parseExtraValues(); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return $str; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function parseExtraValues(){ |
|
| 145 | + public function parseExtraValues() { |
|
| 146 | 146 | $str = ''; |
| 147 | 147 | |
| 148 | 148 | $values = $this->getConfig('extra_values'); |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | $modelName = strtolower($modelName); |
| 161 | 161 | foreach ($fields as $value) { |
| 162 | 162 | if (!is_array($value)) { |
| 163 | - if(!in_array($value, ['image', 'photo', 'profile', 'banner'])) { |
|
| 164 | - $str .= '<td> {{ $' . $modelName . '->' . $value . " }} </td>" . $this->makeTab(1, end($fields) != $value); |
|
| 163 | + if (!in_array($value, ['image', 'photo', 'profile', 'banner'])) { |
|
| 164 | + $str .= '<td> {{ $'.$modelName.'->'.$value." }} </td>".$this->makeTab(1, end($fields) != $value); |
|
| 165 | 165 | } else { |
| 166 | - $str .= '<td><a target="_blank" href="{{ asset($' . $modelName . '->' . $value . ') }}"><img class="rounded-circle img-fluid" width="50" height="50" src="{{ asset($' . $modelName . '->' . $value . ') }}" alt="'.$value.'"></td></a>' . $this->makeTab(1, end($fields) != $value); |
|
| 166 | + $str .= '<td><a target="_blank" href="{{ asset($'.$modelName.'->'.$value.') }}"><img class="rounded-circle img-fluid" width="50" height="50" src="{{ asset($'.$modelName.'->'.$value.') }}" alt="'.$value.'"></td></a>'.$this->makeTab(1, end($fields) != $value); |
|
| 167 | 167 | } |
| 168 | 168 | } else { |
| 169 | 169 | $relationName = array_key_first($value); |
| 170 | - $str .= '<td> {{ $' . $modelName . '->' . $relationName . '->'. $value[array_key_first($value)] .' }} </td>' . $this->makeTab(1, end($fields) != $value); |
|
| 170 | + $str .= '<td> {{ $'.$modelName.'->'.$relationName.'->'.$value[array_key_first($value)].' }} </td>'.$this->makeTab(1, end($fields) != $value); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $field = ucfirst($field); |
| 184 | 184 | } else { |
| 185 | 185 | $relationName = array_key_first($field); |
| 186 | - $field = ucfirst($relationName). ' ' . ucfirst($field[array_key_first($field)]); |
|
| 186 | + $field = ucfirst($relationName).' '.ucfirst($field[array_key_first($field)]); |
|
| 187 | 187 | } |
| 188 | 188 | $str .= "<td> $field </td>".$this->makeTab(6, end($fields) != $field); |
| 189 | 189 | } |
@@ -211,19 +211,19 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | $mode = config('easy_panel.lazy_mode') ? 'wire:model.lazy' : 'wire:model'; |
| 213 | 213 | $array = [ |
| 214 | - 'text' => '<input type="text" '. $mode .'="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 215 | - 'email' => '<input type="email" '. $mode .'="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 216 | - 'number' => '<input type="number" '. $mode .'="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 217 | - 'file' => '<input type="file" wire:model="' . $key . '" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input' . $key . '">', |
|
| 218 | - 'textarea' => '<textarea '.$mode.'="' . $key . '" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
| 219 | - 'password' => '<input type="password" '. $mode .'="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
| 214 | + 'text' => '<input type="text" '.$mode.'="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 215 | + 'email' => '<input type="email" '.$mode.'="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 216 | + 'number' => '<input type="number" '.$mode.'="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 217 | + 'file' => '<input type="file" wire:model="'.$key.'" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input'.$key.'">', |
|
| 218 | + 'textarea' => '<textarea '.$mode.'="'.$key.'" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
| 219 | + 'password' => '<input type="password" '.$mode.'="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
| 220 | 220 | ]; |
| 221 | 221 | $str .= $array[$type]; |
| 222 | 222 | |
| 223 | 223 | return $str; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public function makeTab($count, $newLine = true){ |
|
| 226 | + public function makeTab($count, $newLine = true) { |
|
| 227 | 227 | $count = $count * 4; |
| 228 | 228 | $tabs = str_repeat(' ', $count); |
| 229 | 229 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function handle() |
| 23 | 23 | { |
| 24 | - if(!$this->option('model')){ |
|
| 24 | + if (!$this->option('model')) { |
|
| 25 | 25 | $this->error("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 | } |