@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | Route::view('/', "admin::home")->name('home'); |
| 6 | 6 | |
| 7 | -Route::post('/logout', function (){ |
|
| 7 | +Route::post('/logout', function() { |
|
| 8 | 8 | auth()->logout(); |
| 9 | 9 | return redirect(config('easy_panel.redirect_unauthorized')); |
| 10 | 10 | })->name('logout'); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | $name = ucfirst($crud->name); |
| 16 | 16 | $component = "App\\Http\\Livewire\\Admin\\$name"; |
| 17 | 17 | |
| 18 | - Route::prefix($crud->route)->name("{$crud->route}.")->group(function () use ($component, $crud, $crudConfig) { |
|
| 18 | + Route::prefix($crud->route)->name("{$crud->route}.")->group(function() use ($component, $crud, $crudConfig) { |
|
| 19 | 19 | |
| 20 | 20 | if (@class_exists("$component\\Read")) { |
| 21 | 21 | Route::get('/', "$component\\Read")->name('read'); |
@@ -26,26 +26,26 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | if (@$crudConfig->update and @class_exists("$component\\Update")) { |
| 29 | - Route::get('/update/{' . $crud->name . '}', "$component\\Update")->name('update'); |
|
| 29 | + Route::get('/update/{'.$crud->name.'}', "$component\\Update")->name('update'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | }); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -if(config('easy_panel.todo')){ |
|
| 37 | - Route::prefix('todo')->name('todo.')->group(function (){ |
|
| 36 | +if (config('easy_panel.todo')) { |
|
| 37 | + Route::prefix('todo')->name('todo.')->group(function() { |
|
| 38 | 38 | Route::get('/', \EasyPanel\Http\Livewire\Todo\Lists::class)->name('lists'); |
| 39 | 39 | Route::get('/create', \EasyPanel\Http\Livewire\Todo\Create::class)->name('create'); |
| 40 | 40 | }); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -Route::prefix('crud')->name('crud.')->group(function (){ |
|
| 43 | +Route::prefix('crud')->name('crud.')->group(function() { |
|
| 44 | 44 | Route::get('/', \EasyPanel\Http\Livewire\CRUD\Lists::class)->name('lists'); |
| 45 | 45 | Route::get('/create', \EasyPanel\Http\Livewire\CRUD\Create::class)->name('create'); |
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | -Route::get('setLang', function (){ |
|
| 48 | +Route::get('setLang', function() { |
|
| 49 | 49 | $lang = request()->get('lang'); |
| 50 | 50 | |
| 51 | 51 | session()->put('easypanel_lang', $lang); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | { |
| 14 | 14 | $lang = session()->has('easypanel_lang') |
| 15 | 15 | ? session()->get('easypanel_lang') |
| 16 | - : (config('easy_panel.lang') ?? 'en') .'_panel'; |
|
| 16 | + : (config('easy_panel.lang') ?? 'en').'_panel'; |
|
| 17 | 17 | |
| 18 | 18 | App::setLocale($lang); |
| 19 | 19 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | $files = collect(static::getFiles()); |
| 13 | 13 | |
| 14 | - return $files->mapWithKeys(function ($file, $key){ |
|
| 14 | + return $files->mapWithKeys(function($file, $key) { |
|
| 15 | 15 | preg_match('/(\w+)_panel\.json/i', $file, $m); |
| 16 | 16 | $key = "$m[1]_panel"; |
| 17 | 17 | $value = Str::upper($m[1]); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | foreach (static::getFiles() as $file) { |
| 25 | 25 | $decodedFile = json_decode(File::get($file), 1); |
| 26 | 26 | foreach ($texts as $key => $text) { |
| 27 | - if (array_key_exists($key, $decodedFile)){ |
|
| 27 | + if (array_key_exists($key, $decodedFile)) { |
|
| 28 | 28 | unset($texts[$text]); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $this->validate(); |
| 63 | 63 | |
| 64 | - if (!class_exists($this->model) or ! app()->make($this->model) instanceof Model){ |
|
| 64 | + if (!class_exists($this->model) or !app()->make($this->model) instanceof Model) { |
|
| 65 | 65 | $this->addError('model', __('Namespace is invalid')); |
| 66 | 66 | |
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (!preg_match('/^([a-z]|[0-9])+/', $this->route)){ |
|
| 70 | + if (!preg_match('/^([a-z]|[0-9])+/', $this->route)) { |
|
| 71 | 71 | $this->addError('route', __('Route is invalid')); |
| 72 | 72 | |
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - try{ |
|
| 76 | + try { |
|
| 77 | 77 | $name = $this->getModelName($this->model); |
| 78 | 78 | |
| 79 | 79 | CRUD::create([ |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | '--force' => true |
| 89 | 89 | ]); |
| 90 | 90 | |
| 91 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('CRUD') ])]); |
|
| 92 | - } catch(\Exception $exception){ |
|
| 93 | - $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('UnknownError') ]); |
|
| 91 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('CRUD')])]); |
|
| 92 | + } catch (\Exception $exception) { |
|
| 93 | + $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('UnknownError')]); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | public function render() |
| 102 | 102 | { |
| 103 | 103 | return view('admin::livewire.crud.create') |
| 104 | - ->layout('admin::layouts.app', ['title' => __('CreateTitle', ['name' => __('CRUD') ])]); |
|
| 104 | + ->layout('admin::layouts.app', ['title' => __('CreateTitle', ['name' => __('CRUD')])]); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - private function getModelName($model){ |
|
| 107 | + private function getModelName($model) { |
|
| 108 | 108 | $model = explode('\\', $model); |
| 109 | 109 | |
| 110 | 110 | return end($model); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | foreach ($files as $file) { |
| 122 | 122 | |
| 123 | - if ($this->fileCanNotBeListed($file->getFilename(), $query)){ |
|
| 123 | + if ($this->fileCanNotBeListed($file->getFilename(), $query)) { |
|
| 124 | 124 | continue; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | $this->store = $store; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function setAuthType(bool $hasAuth){ |
|
| 41 | + public function setAuthType(bool $hasAuth) { |
|
| 42 | 42 | $this->hasAuth = $hasAuth; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function setFields(array $fields){ |
|
| 45 | + public function setFields(array $fields) { |
|
| 46 | 46 | $this->fields = $fields; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function setInputs(array $inputs){ |
|
| 49 | + public function setInputs(array $inputs) { |
|
| 50 | 50 | $this->inputs = $inputs; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $fields = array_keys($this->inputs); |
| 99 | 99 | $str = ''; |
| 100 | 100 | |
| 101 | - if(in_array($this->inputName, $fields)){ |
|
| 101 | + if (in_array($this->inputName, $fields)) { |
|
| 102 | 102 | $this->error("Model name must not equal to column names, fix it and rerun command with -f flag"); |
| 103 | 103 | die; |
| 104 | 104 | } |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | foreach ($this->inputs as $key => $field) { |
| 173 | 173 | $newLine = ($field != end($this->inputs) or $this->hasAuth); |
| 174 | - $str .= "'$key' => " . '$this' . "->$key,".$this->makeTab(3, $newLine); |
|
| 174 | + $str .= "'$key' => ".'$this'."->$key,".$this->makeTab(3, $newLine); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - if($this->hasAuth){ |
|
| 177 | + if ($this->hasAuth) { |
|
| 178 | 178 | $str .= "'user_id' => auth()->id(),"; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | /** |
| 185 | 185 | * Create Blade from stub |
| 186 | 186 | */ |
| 187 | - public function parseBlade($stub){ |
|
| 187 | + public function parseBlade($stub) { |
|
| 188 | 188 | $modelName = $this->getModelName($this->parsedModel); |
| 189 | 189 | |
| 190 | 190 | $array = [ |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | /** |
| 264 | 264 | * Tab Maker (Each tabs mean 4 space) |
| 265 | 265 | */ |
| 266 | - public function makeTab($count, $newLine = true){ |
|
| 266 | + public function makeTab($count, $newLine = true) { |
|
| 267 | 267 | $count = $count * 4; |
| 268 | 268 | $tabs = str_repeat(' ', $count); |
| 269 | 269 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | public function normalizeField($field) |
| 281 | 281 | { |
| 282 | - if($field instanceof Field){ |
|
| 282 | + if ($field instanceof Field) { |
|
| 283 | 283 | return $field; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | return Field::title($title); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - public function normalizeInput($key, $input){ |
|
| 292 | - if ($input instanceof BaseInput){ |
|
| 291 | + public function normalizeInput($key, $input) { |
|
| 292 | + if ($input instanceof BaseInput) { |
|
| 293 | 293 | return $input; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function addText($text, $key = null) |
| 14 | 14 | { |
| 15 | - if (array_key_exists($key, $this->texts)){ |
|
| 15 | + if (array_key_exists($key, $this->texts)) { |
|
| 16 | 16 | return; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $this->validate(); |
| 44 | 44 | try { |
| 45 | - $lang = strtolower($this->language) . '_panel'; |
|
| 45 | + $lang = strtolower($this->language).'_panel'; |
|
| 46 | 46 | File::copy(LangManager::getPath('en_panel'), LangManager::getPath($lang)); |
| 47 | 47 | |
| 48 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Translation') ])]); |
|
| 49 | - } catch (\Exception $exception){ |
|
| 48 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Translation')])]); |
|
| 49 | + } catch (\Exception $exception) { |
|
| 50 | 50 | $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => $exception->getMessage()]); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -57,6 +57,6 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | LangManager::updateLanguage($this->selectedLang, $this->texts); |
| 59 | 59 | |
| 60 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('UpdatedMessage', ['name' => __('Translation') ])]); |
|
| 60 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('UpdatedMessage', ['name' => __('Translation')])]); |
|
| 61 | 61 | } |
| 62 | 62 | } |
@@ -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 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->bindCommands(); |
| 61 | 61 | |
| 62 | 62 | // Load Views with 'admin::' prefix |
| 63 | - $this->loadViewsFrom(__DIR__ . '/../resources/views', 'admin'); |
|
| 63 | + $this->loadViewsFrom(__DIR__.'/../resources/views', 'admin'); |
|
| 64 | 64 | |
| 65 | 65 | // Register Middleware |
| 66 | 66 | $this->registerMiddlewareAlias(); |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | private function defineRoutes() |
| 81 | 81 | { |
| 82 | - if(!$this->app->routesAreCached()) { |
|
| 82 | + if (!$this->app->routesAreCached()) { |
|
| 83 | 83 | $middlewares = array_merge(['web', 'isAdmin', 'LangChanger'], config('easy_panel.additional_middlewares')); |
| 84 | 84 | |
| 85 | 85 | Route::prefix(config('easy_panel.route_prefix')) |
| 86 | 86 | ->middleware($middlewares) |
| 87 | - ->name(getRouteName() . '.') |
|
| 88 | - ->group(__DIR__ . '/routes.php'); |
|
| 87 | + ->name(getRouteName().'.') |
|
| 88 | + ->group(__DIR__.'/routes.php'); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | private function mergePublishes() |
| 119 | 119 | { |
| 120 | - $this->publishes([__DIR__ . '/../config/easy_panel_config.php' => config_path('easy_panel.php')], 'easy-panel-config'); |
|
| 120 | + $this->publishes([__DIR__.'/../config/easy_panel_config.php' => config_path('easy_panel.php')], 'easy-panel-config'); |
|
| 121 | 121 | |
| 122 | - $this->publishes([__DIR__ . '/../resources/views' => resource_path('/views/vendor/admin')], 'easy-panel-views'); |
|
| 122 | + $this->publishes([__DIR__.'/../resources/views' => resource_path('/views/vendor/admin')], 'easy-panel-views'); |
|
| 123 | 123 | |
| 124 | - $this->publishes([__DIR__ . '/../resources/assets' => public_path('/assets/admin')], 'easy-panel-styles'); |
|
| 124 | + $this->publishes([__DIR__.'/../resources/assets' => public_path('/assets/admin')], 'easy-panel-styles'); |
|
| 125 | 125 | |
| 126 | - $this->publishes([__DIR__ . '/../database/migrations/2020_09_05_999999_create_todos_table.php' => base_path('/database/migrations/' . date('Y_m_d') . '_999999_create_admin_todos_table.php')], 'easy-panel-todo'); |
|
| 126 | + $this->publishes([__DIR__.'/../database/migrations/2020_09_05_999999_create_todos_table.php' => base_path('/database/migrations/'.date('Y_m_d').'_999999_create_admin_todos_table.php')], 'easy-panel-todo'); |
|
| 127 | 127 | |
| 128 | 128 | $this->publishes([ |
| 129 | - __DIR__ . '/../database/migrations/2021_07_17_999999_create_cruds_table.php' => base_path('/database/migrations/' . date('Y_m_d') . '_999999_create_cruds_table.php'), |
|
| 130 | - __DIR__ . '/../database/migrations/2021_12_17_999999_create_user_admins_table.php' => base_path('/database/migrations/' . date('Y_m_d') . '_999999_create_user_admins_table.php') |
|
| 129 | + __DIR__.'/../database/migrations/2021_07_17_999999_create_cruds_table.php' => base_path('/database/migrations/'.date('Y_m_d').'_999999_create_cruds_table.php'), |
|
| 130 | + __DIR__.'/../database/migrations/2021_12_17_999999_create_user_admins_table.php' => base_path('/database/migrations/'.date('Y_m_d').'_999999_create_user_admins_table.php') |
|
| 131 | 131 | ], 'easy-panel-migration'); |
| 132 | 132 | |
| 133 | 133 | $this->publishes([__DIR__.'/../resources/lang' => app()->langPath()], 'easy-panel-lang'); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $model = !$this->app->runningUnitTests() ? config('easy_panel.user_model') : User::class; |
| 162 | 162 | |
| 163 | - $model::resolveRelationUsing('panelAdmin', function ($userModel){ |
|
| 163 | + $model::resolveRelationUsing('panelAdmin', function($userModel) { |
|
| 164 | 164 | return $userModel->hasOne(PanelAdmin::class)->latest(); |
| 165 | 165 | }); |
| 166 | 166 | } |