@@ -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 | } |
@@ -39,7 +39,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 = $this->parseRelationName(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 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $str .= '<div class="form-group">'.$this->makeTab(4); |
183 | 183 | $str .= '<label for="input'.$key.'" class="col-sm-2 control-label">'.ucfirst($key).'</label>'.$this->makeTab(4); |
184 | 184 | $str = $this->inputsHTML($type, $key, $str).$this->makeTab(4); |
185 | - $str .='@error("'.$key.'") <div class="invalid-feedback">{{ $message }}</div> @enderror'.$this->makeTab(3); |
|
185 | + $str .= '@error("'.$key.'") <div class="invalid-feedback">{{ $message }}</div> @enderror'.$this->makeTab(3); |
|
186 | 186 | $str .= '</div>'.$this->makeTab(3); |
187 | 187 | } |
188 | 188 | |
@@ -192,28 +192,28 @@ discard block |
||
192 | 192 | public function inputsHTML($type, $key, string $str): string |
193 | 193 | { |
194 | 194 | $array = [ |
195 | - 'text' => '<input type="text" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
196 | - 'email' => '<input type="email" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
197 | - 'number' => '<input type="number" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
198 | - 'file' => '<input type="file" wire:model="' . $key . '" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input' . $key . '">', |
|
199 | - 'textarea' => '<textarea wire:model="' . $key . '" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
200 | - 'password' => '<input type="password" wire:model.lazy="' . $key . '" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input' . $key . '">', |
|
195 | + 'text' => '<input type="text" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
196 | + 'email' => '<input type="email" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
197 | + 'number' => '<input type="number" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
198 | + 'file' => '<input type="file" wire:model="'.$key.'" class="form-control-file @error(\''.$key.'\')is-invalid @enderror" id="input'.$key.'">', |
|
199 | + 'textarea' => '<textarea wire:model="'.$key.'" class="form-control @error(\''.$key.'\')is-invalid @enderror"></textarea>', |
|
200 | + 'password' => '<input type="password" wire:model.lazy="'.$key.'" class="form-control @error(\''.$key.'\') is-invalid @enderror" id="input'.$key.'">', |
|
201 | 201 | ]; |
202 | 202 | $str .= $array[$type]; |
203 | 203 | |
204 | 204 | return $str; |
205 | 205 | } |
206 | 206 | |
207 | - public function makeTab($count, $newLine = true){ |
|
207 | + public function makeTab($count, $newLine = true) { |
|
208 | 208 | $count = $count * 4; |
209 | 209 | $tabs = str_repeat(' ', $count); |
210 | 210 | |
211 | 211 | return $newLine ? "\n".$tabs : $tabs; |
212 | 212 | } |
213 | 213 | |
214 | - public function parseRelationName($column){ |
|
214 | + public function parseRelationName($column) { |
|
215 | 215 | $relations = $this->getConfig('relations'); |
216 | - if(array_key_exists($column, $relations)){ |
|
216 | + if (array_key_exists($column, $relations)) { |
|
217 | 217 | return $relations[$column]; |
218 | 218 | } |
219 | 219 |