@@ -40,17 +40,17 @@ |
||
40 | 40 | |
41 | 41 | protected function getStub() |
42 | 42 | { |
43 | - return __DIR__ . DIRECTORY_SEPARATOR. "..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."{$this->file}.stub"; |
|
43 | + return __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."{$this->file}.stub"; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | private function buildBlade() |
47 | 47 | { |
48 | - $stub = $this->files->get(__DIR__ . DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."blade".DIRECTORY_SEPARATOR."{$this->file}.blade.stub"); |
|
48 | + $stub = $this->files->get(__DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."stub".DIRECTORY_SEPARATOR."blade".DIRECTORY_SEPARATOR."{$this->file}.blade.stub"); |
|
49 | 49 | $newStub = $this->stubParser->parseBlade($stub); |
50 | 50 | |
51 | 51 | $path = $this->viewPath("livewire".DIRECTORY_SEPARATOR."admin".DIRECTORY_SEPARATOR."{$this->getNameInput()}".DIRECTORY_SEPARATOR."{$this->file}.blade.php"); |
52 | 52 | |
53 | - if (! $this->files->isDirectory(dirname($path))) { |
|
53 | + if (!$this->files->isDirectory(dirname($path))) { |
|
54 | 54 | $this->files->makeDirectory(dirname($path), 0755, true); |
55 | 55 | } |
56 | 56 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $decodedFile = json_decode(File::get($file), 1); |
51 | 51 | $texts = $this->texts; |
52 | 52 | foreach ($texts as $key => $text) { |
53 | - if (array_key_exists($key, $decodedFile)){ |
|
53 | + if (array_key_exists($key, $decodedFile)) { |
|
54 | 54 | unset($texts[$text]); |
55 | 55 | } |
56 | 56 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - public function parseBlade($stub){ |
|
62 | + public function parseBlade($stub) { |
|
63 | 63 | $modelName = $this->getModelName($this->parsedModel); |
64 | 64 | |
65 | 65 | $array = [ |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | return str_replace(array_keys($array), array_values($array), $stub); |
76 | 76 | } |
77 | 77 | |
78 | - public function getConfig($key, $action = null){ |
|
78 | + public function getConfig($key, $action = null) { |
|
79 | 79 | $action = $action ?? $this->inputName; |
80 | 80 | |
81 | 81 | return config("easy_panel.crud.$action.$key") ?: []; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $fields = array_keys($fields); |
94 | 94 | $str = ''; |
95 | 95 | |
96 | - if(in_array($this->inputName, $fields)){ |
|
96 | + if (in_array($this->inputName, $fields)) { |
|
97 | 97 | $this->error("Model name must not equal to column names, fix it and rerun command with -f flag"); |
98 | 98 | die; |
99 | 99 | } |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | |
154 | 154 | foreach ($fields as $key => $field) { |
155 | 155 | $newLine = ($field != end($fields) or $this->getConfig('with_auth')); |
156 | - $str .= "'$key' => " . '$this' . "->$key,".$this->makeTab(3, $newLine); |
|
156 | + $str .= "'$key' => ".'$this'."->$key,".$this->makeTab(3, $newLine); |
|
157 | 157 | } |
158 | 158 | |
159 | - if($this->getConfig('with_auth')){ |
|
159 | + if ($this->getConfig('with_auth')) { |
|
160 | 160 | $str .= "'user_id' => auth()->id(),"; |
161 | 161 | } |
162 | 162 | |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | $modelName = strtolower($modelName); |
171 | 171 | foreach ($fields as $value) { |
172 | 172 | if (!is_array($value)) { |
173 | - if(!in_array($value, ['image', 'photo', 'profile', 'banner'])) { |
|
174 | - $str .= '<td> {{ $' . $modelName . '->' . $value . " }} </td>" . $this->makeTab(1, end($fields) != $value); |
|
173 | + if (!in_array($value, ['image', 'photo', 'profile', 'banner'])) { |
|
174 | + $str .= '<td> {{ $'.$modelName.'->'.$value." }} </td>".$this->makeTab(1, end($fields) != $value); |
|
175 | 175 | } else { |
176 | - $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.'"></a></td>' . $this->makeTab(1, end($fields) != $value); |
|
176 | + $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.'"></a></td>'.$this->makeTab(1, end($fields) != $value); |
|
177 | 177 | } |
178 | 178 | } else { |
179 | 179 | $relationName = array_key_first($value); |
180 | - $str .= '<td> {{ $' . $modelName . '->' . $relationName . '->'. $value[array_key_first($value)] .' }} </td>' . $this->makeTab(1, end($fields) != $value); |
|
180 | + $str .= '<td> {{ $'.$modelName.'->'.$relationName.'->'.$value[array_key_first($value)].' }} </td>'.$this->makeTab(1, end($fields) != $value); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $str .= "<td style='cursor: pointer' wire:click=\"sort('$sortName')\"> <i class='fa @if(".'$sortType'." == 'desc' and ".'$sortColumn'." == '$sortName') fa-sort-amount-down ml-2 @elseif(".'$sortType == '."'asc' and ".'$sortColumn'." == '$sortName') fa-sort-amount-up ml-2 @endif'></i> {{ __('$field') }} </td>".$this->makeTab(6, end($fields) != $field); |
196 | 196 | } else { |
197 | 197 | $relationName = array_key_first($field); |
198 | - $field = ucfirst($relationName). ' ' . ucfirst($field[array_key_first($field)]); |
|
198 | + $field = ucfirst($relationName).' '.ucfirst($field[array_key_first($field)]); |
|
199 | 199 | $str .= "<td> {{ __('$field') }} </td>".$this->makeTab(6, end($fields) != $field); |
200 | 200 | } |
201 | 201 | $this->texts[$field] = $field; |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | return $str; |
219 | 219 | } |
220 | 220 | |
221 | - public function makeTab($count, $newLine = true){ |
|
221 | + public function makeTab($count, $newLine = true) { |
|
222 | 222 | $count = $count * 4; |
223 | 223 | $tabs = str_repeat(' ', $count); |
224 | 224 |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | |
24 | 24 | public function handle() |
25 | 25 | { |
26 | - if(!$this->option('model')){ |
|
26 | + if (!$this->option('model')) { |
|
27 | 27 | $this->error("Model option must have a value"); |
28 | 28 | return; |
29 | 29 | } |
30 | 30 | |
31 | 31 | $name = strtolower($this->getNameInput()); |
32 | 32 | |
33 | - if($name != strtolower($this->option('model'))){ |
|
33 | + if ($name != strtolower($this->option('model'))) { |
|
34 | 34 | $this->warn("'{$name}' must be equal to model name"); |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $path = resource_path("cruds/{$name}.php"); |
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}' already exists in CRUDs config"); |
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | - if (! $this->files->isDirectory(dirname($path))) { |
|
45 | + if (!$this->files->isDirectory(dirname($path))) { |
|
46 | 46 | $this->files->makeDirectory(dirname($path), 0755, true); |
47 | 47 | } |
48 | 48 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $model = $this->qualifyModel($this->option('model')); |
78 | 78 | |
79 | - if(!class_exists($model)){ |
|
79 | + if (!class_exists($model)) { |
|
80 | 80 | $this->warn("Model option should be valid and model should be exist"); |
81 | 81 | die(); |
82 | 82 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | private function withAuth() |
88 | 88 | { |
89 | 89 | $fillableList = $this->getFillableList(); |
90 | - if(!in_array('user_id', $fillableList)){ |
|
90 | + if (!in_array('user_id', $fillableList)) { |
|
91 | 91 | return 'true'; |
92 | 92 | } |
93 | 93 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | { |
106 | 106 | $fillableList = $this->getFillableList(); |
107 | 107 | $array = []; |
108 | - foreach ($fillableList as $fillable){ |
|
109 | - if(!Str::contains($fillable, 'id')){ |
|
108 | + foreach ($fillableList as $fillable) { |
|
109 | + if (!Str::contains($fillable, 'id')) { |
|
110 | 110 | $array[] = "'$fillable'"; |
111 | 111 | } |
112 | 112 | } |
@@ -27,12 +27,12 @@ |
||
27 | 27 | $this->action = $action; |
28 | 28 | } |
29 | 29 | |
30 | - public function render(){ |
|
30 | + public function render() { |
|
31 | 31 | $name = $this->name; |
32 | 32 | |
33 | 33 | // Create an instance of input class |
34 | 34 | // then call handle() method to get input as a steing |
35 | - if(!is_array($this->type)) { |
|
35 | + if (!is_array($this->type)) { |
|
36 | 36 | $inputStringClass = static::classMap[$this->type]; |
37 | 37 | $input = (new $inputStringClass())->handle($name); |
38 | 38 | } else { |
@@ -8,8 +8,8 @@ |
||
8 | 8 | public function handle($name, $values, $action) |
9 | 9 | { |
10 | 10 | return "<select wire:model='$name' class=\"form-control @error('$name') is-invalid @enderror\" id='input$name'> |
11 | - @foreach(config('easy_panel.crud.$action.fields.$name')['select'] as " . '$key => $value' . ") |
|
12 | - <option value='{{ " . '$key' . " }}'>{{ " . '$value' . " }}</option> |
|
11 | + @foreach(config('easy_panel.crud.$action.fields.$name')['select'] as ".'$key => $value'.") |
|
12 | + <option value='{{ " . '$key'." }}'>{{ ".'$value'." }}</option> |
|
13 | 13 | @endforeach |
14 | 14 | </select>"; |
15 | 15 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | public function register() |
35 | 35 | { |
36 | 36 | // Here we merge config with 'easy_panel' key |
37 | - $this->mergeConfigFrom(__DIR__ . '/../config/easy_panel_config.php', 'easy_panel'); |
|
37 | + $this->mergeConfigFrom(__DIR__.'/../config/easy_panel_config.php', 'easy_panel'); |
|
38 | 38 | |
39 | 39 | // Check the status of module |
40 | - if(!config('easy_panel.enable')) { |
|
40 | + if (!config('easy_panel.enable')) { |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function boot() |
49 | 49 | { |
50 | - if(!config('easy_panel.enable')) { |
|
50 | + if (!config('easy_panel.enable')) { |
|
51 | 51 | return; |
52 | 52 | } |
53 | 53 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Load Views with 'admin::' prefix |
64 | - $this->loadViewsFrom(__DIR__ . '/../resources/views', 'admin'); |
|
64 | + $this->loadViewsFrom(__DIR__.'/../resources/views', 'admin'); |
|
65 | 65 | |
66 | 66 | // Register Middleware |
67 | 67 | $this->registerMiddlewareAlias(); |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | |
76 | 76 | private function defineRoutes() |
77 | 77 | { |
78 | - if(!$this->app->routesAreCached()) { |
|
78 | + if (!$this->app->routesAreCached()) { |
|
79 | 79 | Route::prefix(config('easy_panel.route_prefix')) |
80 | 80 | ->middleware(['web', 'auth', 'isAdmin', 'LangChanger']) |
81 | - ->name(getRouteName() . '.') |
|
82 | - ->group(__DIR__ . '/routes.php'); |
|
81 | + ->name(getRouteName().'.') |
|
82 | + ->group(__DIR__.'/routes.php'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | |
106 | 106 | private function mergePublishes() |
107 | 107 | { |
108 | - $this->publishes([__DIR__ . '/../config/easy_panel_config.php' => config_path('easy_panel.php')], 'easy-panel-config'); |
|
108 | + $this->publishes([__DIR__.'/../config/easy_panel_config.php' => config_path('easy_panel.php')], 'easy-panel-config'); |
|
109 | 109 | |
110 | - $this->publishes([__DIR__ . '/../resources/views' => resource_path('/views/vendor/admin')], 'easy-panel-views'); |
|
110 | + $this->publishes([__DIR__.'/../resources/views' => resource_path('/views/vendor/admin')], 'easy-panel-views'); |
|
111 | 111 | |
112 | - $this->publishes([__DIR__ . '/../resources/assets' => public_path('/assets/admin')], 'easy-panel-styles'); |
|
112 | + $this->publishes([__DIR__.'/../resources/assets' => public_path('/assets/admin')], 'easy-panel-styles'); |
|
113 | 113 | |
114 | - $this->publishes([__DIR__ . '/../database/migrations/2020_09_05_99999_create_todos_table.php' => base_path('/database/migrations/' . date('Y_m_d') . '_99999_create_admin_todos_table.php')], 'easy-panel-migrations'); |
|
114 | + $this->publishes([__DIR__.'/../database/migrations/2020_09_05_99999_create_todos_table.php' => base_path('/database/migrations/'.date('Y_m_d').'_99999_create_admin_todos_table.php')], 'easy-panel-migrations'); |
|
115 | 115 | |
116 | 116 | $this->publishes([__DIR__.'/../resources/lang' => resource_path('/lang')], 'easy-panel-lang'); |
117 | 117 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | public function handle($request, Closure $next) |
12 | 12 | { |
13 | - if(!AuthFacade::checkIsAdmin(auth()->user()->id)){ |
|
13 | + if (!AuthFacade::checkIsAdmin(auth()->user()->id)) { |
|
14 | 14 | return redirect(config('easy_panel.redirect_unauthorized')); |
15 | 15 | } |
16 | 16 |