@@ -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,20 +26,20 @@ 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 | }); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | ]); |
25 | 25 | |
26 | 26 | $this->crud->delete(); |
27 | - $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('Todo') ] )]); |
|
27 | + $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('Todo')])]); |
|
28 | 28 | $this->emit('crudUpdated'); |
29 | 29 | } |
30 | 30 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | 'built' => true |
40 | 40 | ]); |
41 | 41 | |
42 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD Created successfully') ] ); |
|
42 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD Created successfully')]); |
|
43 | 43 | $this->emit('crudUpdated'); |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'active' => false |
50 | 50 | ]); |
51 | 51 | |
52 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD was inactivated') ] ); |
|
52 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD was inactivated')]); |
|
53 | 53 | $this->emit('crudUpdated'); |
54 | 54 | } |
55 | 55 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | 'active' => true |
60 | 60 | ]); |
61 | 61 | |
62 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD was activated') ] ); |
|
62 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD was activated')]); |
|
63 | 63 | $this->emit('crudUpdated'); |
64 | 64 | } |
65 | 65 |
@@ -99,7 +99,7 @@ |
||
99 | 99 | ]; |
100 | 100 | } |
101 | 101 | |
102 | - private function setCRUDInstance(){ |
|
102 | + private function setCRUDInstance() { |
|
103 | 103 | $modelName = $this->getNameInput(); |
104 | 104 | |
105 | 105 | return $this->crudInstance = getCrudConfig($modelName); |
@@ -15,10 +15,9 @@ |
||
15 | 15 | public function handle() |
16 | 16 | { |
17 | 17 | $names = $this->argument('name') ? |
18 | - [$this->argument('name')] : |
|
19 | - CRUD::query()->where('active', true)->pluck('name')->toArray(); |
|
18 | + [$this->argument('name')] : CRUD::query()->where('active', true)->pluck('name')->toArray(); |
|
20 | 19 | |
21 | - if(is_null($names)) { |
|
20 | + if (is_null($names)) { |
|
22 | 21 | throw new CommandNotFoundException("There is no action in config file"); |
23 | 22 | } |
24 | 23 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('cruds', function (Blueprint $table) { |
|
16 | + Schema::create('cruds', function(Blueprint $table) { |
|
17 | 17 | $table->id(); |
18 | 18 | $table->string('name')->unique(); |
19 | 19 | $table->string('model')->unique(); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | $path = base_path("app/CRUD/{$name}Component.php"); |
26 | 26 | |
27 | - if($this->files->exists($path) and !$this->option('force')){ |
|
27 | + if ($this->files->exists($path) and !$this->option('force')) { |
|
28 | 28 | $this->warn("'{$name}Component.php' already exists in CRUD directory"); |
29 | 29 | return; |
30 | 30 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $model = $this->qualifyModel($this->getNameInput()); |
63 | 63 | |
64 | - if(!class_exists($model)){ |
|
64 | + if (!class_exists($model)) { |
|
65 | 65 | $this->warn("Model option should be valid and model should be exist"); |
66 | 66 | die(); |
67 | 67 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | private function withAuth() |
73 | 73 | { |
74 | 74 | $fillableList = $this->getFillableList(); |
75 | - if(!in_array('user_id', $fillableList)){ |
|
75 | + if (!in_array('user_id', $fillableList)) { |
|
76 | 76 | return 'true'; |
77 | 77 | } |
78 | 78 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | { |
91 | 91 | $fillableList = $this->getFillableList(); |
92 | 92 | $array = []; |
93 | - foreach ($fillableList as $fillable){ |
|
94 | - if(!Str::contains($fillable, 'id')){ |
|
93 | + foreach ($fillableList as $fillable) { |
|
94 | + if (!Str::contains($fillable, 'id')) { |
|
95 | 95 | $array[] = "'$fillable'"; |
96 | 96 | } |
97 | 97 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | use EasyPanel\Contracts\CRUDComponent; |
4 | 4 | |
5 | -if(! function_exists('getRouteName')) { |
|
6 | - function getRouteName(){ |
|
5 | +if (!function_exists('getRouteName')) { |
|
6 | + function getRouteName() { |
|
7 | 7 | $routeName = config('easy_panel.route_prefix'); |
8 | 8 | $routeName = trim($routeName, '/'); |
9 | 9 | $routeName = str_replace('/', '.', $routeName); |
@@ -11,17 +11,17 @@ discard block |
||
11 | 11 | } |
12 | 12 | } |
13 | 13 | |
14 | -if(! function_exists('getCrudConfig')) { |
|
15 | - function getCrudConfig($name){ |
|
14 | +if (!function_exists('getCrudConfig')) { |
|
15 | + function getCrudConfig($name) { |
|
16 | 16 | $namespace = "\\App\\CRUD\\{$name}Component"; |
17 | 17 | |
18 | - if (!class_exists($namespace)){ |
|
18 | + if (!class_exists($namespace)) { |
|
19 | 19 | abort(403, "Class with {$namespace} namespace doesn't exist"); |
20 | 20 | } |
21 | 21 | |
22 | 22 | $instance = app()->make($namespace); |
23 | 23 | |
24 | - if (!$instance instanceof CRUDComponent){ |
|
24 | + if (!$instance instanceof CRUDComponent) { |
|
25 | 25 | abort(403, "{$namespace} should implement CRUDComponent interface"); |
26 | 26 | } |
27 | 27 | |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -if(! function_exists('crud')) { |
|
33 | - function crud($name){ |
|
32 | +if (!function_exists('crud')) { |
|
33 | + function crud($name) { |
|
34 | 34 | return \EasyPanel\Models\CRUD::query()->where('name', $name)->first(); |
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | -if(! function_exists('get_icon')) { |
|
39 | - function get_icon($type){ |
|
38 | +if (!function_exists('get_icon')) { |
|
39 | + function get_icon($type) { |
|
40 | 40 | $array = [ |
41 | 41 | 'file-text' => ['posts', 'article', 'stories', 'post', 'articles', 'story'], |
42 | 42 | 'users' => ['users', 'user', 'accounts', 'account', 'admins', 'admin', 'employee', 'employees'], |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | 'truck' => ['product', 'products', 'shops', 'shop'], |
54 | 54 | 'message-circle' => ['comments', 'messages', 'pm', 'comment', 'message', 'chats', 'chat'], |
55 | 55 | ]; |
56 | - foreach ($array as $key => $arrayValues){ |
|
57 | - if(in_array($type, $arrayValues)){ |
|
56 | + foreach ($array as $key => $arrayValues) { |
|
57 | + if (in_array($type, $arrayValues)) { |
|
58 | 58 | $val = $key; |
59 | 59 | } |
60 | 60 | } |
@@ -55,19 +55,19 @@ discard block |
||
55 | 55 | { |
56 | 56 | $this->validate(); |
57 | 57 | |
58 | - if (!class_exists($this->model) or ! app()->make($this->model) instanceof Model){ |
|
58 | + if (!class_exists($this->model) or !app()->make($this->model) instanceof Model) { |
|
59 | 59 | $this->addError('model', __('Namespace is invalid')); |
60 | 60 | |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - if (!preg_match('/^([a-z]|[0-9])+/', $this->route)){ |
|
64 | + if (!preg_match('/^([a-z]|[0-9])+/', $this->route)) { |
|
65 | 65 | $this->addError('route', __('Route is invalid')); |
66 | 66 | |
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - try{ |
|
70 | + try { |
|
71 | 71 | $name = strtolower($this->getModelName($this->model)); |
72 | 72 | CRUD::create([ |
73 | 73 | 'model' => trim($this->model, '\\'), |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | '--force' => true |
81 | 81 | ]); |
82 | 82 | |
83 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('CRUD') ])]); |
|
84 | - } catch(\Exception $exception){ |
|
85 | - $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('UnknownError') ]); |
|
83 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('CRUD')])]); |
|
84 | + } catch (\Exception $exception) { |
|
85 | + $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('UnknownError')]); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ->layout('admin::layouts.app'); |
97 | 97 | } |
98 | 98 | |
99 | - private function getModelName($model){ |
|
99 | + private function getModelName($model) { |
|
100 | 100 | $model = explode('\\', $model); |
101 | 101 | |
102 | 102 | return end($model); |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $files = File::exists(app_path('/Models')) ? File::files(app_path('/Models')) : File::allFiles(app_path('/')); |
108 | 108 | $array = []; |
109 | 109 | foreach ($files as $file) { |
110 | - if (!Str::contains($file->getFilename(), '.php') or (!is_null($query) and !Str::contains(Str::lower($file->getFilename()), Str::lower($query)))){ |
|
110 | + if (!Str::contains($file->getFilename(), '.php') or (!is_null($query) and !Str::contains(Str::lower($file->getFilename()), Str::lower($query)))) { |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $namespace = File::exists(app_path('/Models')) ? "App\\Models" : "\\App"; |
115 | 115 | $fileName = str_replace('.php', null, $file->getFilename()); |
116 | - $fullNamespace = $namespace."\\{$fileName}"; |
|
116 | + $fullNamespace = $namespace."\\{$fileName}"; |
|
117 | 117 | |
118 | 118 | if (app()->make($fullNamespace) instanceof Model) { |
119 | 119 | $array[] = $fullNamespace; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | $names = (array) $this->argument('name') ?: CRUD::query()->where('active', true)->pluck('name')->toArray(); |
19 | 19 | |
20 | - if($names == null) { |
|
20 | + if ($names == null) { |
|
21 | 21 | throw new CommandNotFoundException("There is no action in database"); |
22 | 22 | } |
23 | 23 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | if ($this->askResult($name)) { |
31 | 31 | File::deleteDirectory(resource_path("/views/livewire/admin/$name")); |
32 | - File::deleteDirectory(app_path("/Http/Livewire/Admin/" . ucfirst($name))); |
|
32 | + File::deleteDirectory(app_path("/Http/Livewire/Admin/".ucfirst($name))); |
|
33 | 33 | File::delete(app_path("/CRUD/".ucfirst($name)."Component.php")); |
34 | 34 | $this->info("{$name} files were deleted, make sure you will delete {$name} value from actions in config"); |
35 | 35 | CRUD::query()->where('name', $name)->delete(); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function askResult($name) |
44 | 44 | { |
45 | - if($this->option('force')) { |
|
45 | + if ($this->option('force')) { |
|
46 | 46 | return true; |
47 | 47 | } |
48 | 48 | $result = $this->confirm("Do you really want to delete {$name} files ?", true); |