@@ -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' => __('CRUD') ] )]); |
|
27 | + $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('CRUD')])]); |
|
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 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::table('cruds', function (Blueprint $table) { |
|
16 | + Schema::table('cruds', function(Blueprint $table) { |
|
17 | 17 | $table->boolean('with_acl')->default(false); |
18 | 18 | $table->boolean('with_policy')->default(false); |
19 | 19 | }); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function down() |
28 | 28 | { |
29 | - Schema::table('cruds', function (Blueprint $table) { |
|
29 | + Schema::table('cruds', function(Blueprint $table) { |
|
30 | 30 | $table->dropColumn(['with_acl', 'with_policy']); |
31 | 31 | }); |
32 | 32 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | UserProviderFacade::deleteAdmin($this->admin->id); |
28 | 28 | |
29 | - $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('Admin') ] )]); |
|
29 | + $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('Admin')])]); |
|
30 | 30 | $this->emit('adminsUpdated'); |
31 | 31 | } |
32 | 32 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | private function fixAccessKeys() |
21 | 21 | { |
22 | - foreach($this->access as $key => $value) { |
|
22 | + foreach ($this->access as $key => $value) { |
|
23 | 23 | unset($this->access[$key]); |
24 | 24 | $key = str_replace('-', '.', $key); |
25 | 25 | $this->access[$key] = $value; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | try { |
36 | 36 | Role::create(['name' => $this->name, 'permissions' => $this->fixAccessKeys()]); |
37 | 37 | |
38 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Role') ])]); |
|
39 | - } catch (\Exception $exception){ |
|
38 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Role')])]); |
|
39 | + } catch (\Exception $exception) { |
|
40 | 40 | $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => $exception->getMessage()]); |
41 | 41 | } |
42 | 42 | |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | $permissions = ACL::getRoutes(); |
49 | 49 | |
50 | 50 | return view('admin::livewire.role.create', compact('permissions')) |
51 | - ->layout('admin::layouts.app', ['title' => __('CreateTitle', ['name' => __('Role') ])]); |
|
51 | + ->layout('admin::layouts.app', ['title' => __('CreateTitle', ['name' => __('Role')])]); |
|
52 | 52 | } |
53 | 53 | } |
@@ -36,11 +36,13 @@ |
||
36 | 36 | |
37 | 37 | public function update() |
38 | 38 | { |
39 | - if ($this->getRules()) |
|
40 | - $this->validate(); |
|
39 | + if ($this->getRules()) { |
|
40 | + $this->validate(); |
|
41 | + } |
|
41 | 42 | |
42 | - if ($this->selectedRoles[0] == "null") |
|
43 | - $this->selectedRoles = []; |
|
43 | + if ($this->selectedRoles[0] == "null") { |
|
44 | + $this->selectedRoles = []; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | $this->admin->roles()->sync($this->selectedRoles); |
46 | 48 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | $this->role->delete(); |
28 | 28 | |
29 | - $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('Role') ] )]); |
|
29 | + $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('Role')])]); |
|
30 | 30 | $this->emit('roleUpdated'); |
31 | 31 | } |
32 | 32 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | private function fixAccessKeys() |
25 | 25 | { |
26 | - foreach($this->access as $key => $value) { |
|
26 | + foreach ($this->access as $key => $value) { |
|
27 | 27 | unset($this->access[$key]); |
28 | 28 | $key = str_replace('-', '.', $key); |
29 | 29 | $this->access[$key] = is_array($value) ? array_filter($value) : $value; |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | try { |
55 | 55 | Role::create(['name' => $this->name, 'permissions' => $this->fixAccessKeys()]); |
56 | 56 | |
57 | - $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Role') ])]); |
|
58 | - } catch (\Exception $exception){ |
|
57 | + $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CreatedMessage', ['name' => __('Role')])]); |
|
58 | + } catch (\Exception $exception) { |
|
59 | 59 | $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => $exception->getMessage()]); |
60 | 60 | } |
61 | 61 | |
@@ -67,6 +67,6 @@ discard block |
||
67 | 67 | $this->permissionsData = ACL::getRoutes(); |
68 | 68 | |
69 | 69 | return view('admin::livewire.role.create', ['permissions' => $this->permissionsData]) |
70 | - ->layout('admin::layouts.app', ['title' => __('CreateTitle', ['name' => __('Role') ])]); |
|
70 | + ->layout('admin::layouts.app', ['title' => __('CreateTitle', ['name' => __('Role')])]); |
|
71 | 71 | } |
72 | 72 | } |
@@ -55,8 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | public function update() |
57 | 57 | { |
58 | - if ($this->getRules()) |
|
59 | - $this->validate(); |
|
58 | + if ($this->getRules()) { |
|
59 | + $this->validate(); |
|
60 | + } |
|
60 | 61 | |
61 | 62 | if ($this->role->is_super_admin()) { |
62 | 63 | $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('CannotUpdateMessage', ['name' => __('Role')])]); |
@@ -84,8 +85,9 @@ discard block |
||
84 | 85 | $dashKey = str_replace('.', '-', $key); |
85 | 86 | $value = is_array($value) ? array_filter($value) : $value; |
86 | 87 | |
87 | - if (empty($value)) |
|
88 | - continue; |
|
88 | + if (empty($value)) { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | |
90 | 92 | $this->access[$dashKey] = $value; |
91 | 93 |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | private function setSelectedAccess($rolePermissions) |
82 | 82 | { |
83 | - foreach($rolePermissions as $key => $value) { |
|
83 | + foreach ($rolePermissions as $key => $value) { |
|
84 | 84 | $dashKey = str_replace('.', '-', $key); |
85 | 85 | $value = is_array($value) ? array_filter($value) : $value; |
86 | 86 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | { |
98 | 98 | $access = $this->access; |
99 | 99 | |
100 | - foreach($access as $key => $value) { |
|
100 | + foreach ($access as $key => $value) { |
|
101 | 101 | unset($access[$key]); |
102 | 102 | $key = str_replace('-', '.', $key); |
103 | 103 | $access[$key] = is_array($value) ? array_filter($value) : $value; |
@@ -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 (!file_exists(app_path("/CRUD/{$name}Component.php")) or !class_exists($namespace)){ |
|
18 | + if (!file_exists(app_path("/CRUD/{$name}Component.php")) or !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,13 +29,13 @@ 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('hasPermission')) { |
|
38 | +if (!function_exists('hasPermission')) { |
|
39 | 39 | function hasPermission($routeName, $withAcl, $withPolicy = false, $entity = []) { |
40 | 40 | $showButton = true; |
41 | 41 |