@@ -125,7 +125,7 @@ |
||
125 | 125 | protected function getBrowserItems($scopes = []) |
126 | 126 | { |
127 | 127 | // Exclude everyone group from browsers |
128 | - return parent::getBrowserItems($scopes)->filter(function ($item) { |
|
128 | + return parent::getBrowserItems($scopes)->filter(function($item) { |
|
129 | 129 | return !$item->isEveryoneGroup(); |
130 | 130 | })->values(); |
131 | 131 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $this->checkPermissionAvailable($name, Permission::SCOPE_GLOBAL); |
36 | 36 | |
37 | - $permission = Permission::firstOrCreate(['name' => $name,]); |
|
37 | + $permission = Permission::firstOrCreate(['name' => $name, ]); |
|
38 | 38 | |
39 | 39 | // check the existence to avoid duplicate records on pivot table |
40 | 40 | if (!$this->permissions()->global()->where('name', $name)->exists()) { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function revokeAllModulePermission($permissionableType) |
106 | 106 | { |
107 | - foreach(Permission::ofModel($permissionableType)->get() as $permission) { |
|
107 | + foreach (Permission::ofModel($permissionableType)->get() as $permission) { |
|
108 | 108 | $this->permissions()->module()->detach($permission->id); |
109 | 109 | } |
110 | 110 | } |
@@ -111,9 +111,9 @@ |
||
111 | 111 | */ |
112 | 112 | public static function permissionableParentModuleItems() |
113 | 113 | { |
114 | - return self::permissionableModules()->filter(function ($module) { |
|
114 | + return self::permissionableModules()->filter(function($module) { |
|
115 | 115 | return !strpos($module, '.'); |
116 | - })->mapWithKeys(function ($module) { |
|
116 | + })->mapWithKeys(function($module) { |
|
117 | 117 | return [$module => getRepositoryByModuleName($module)->get([], [], [], -1)]; |
118 | 118 | }); |
119 | 119 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function viewableItems() |
165 | 165 | { |
166 | - return Permission::where('name', 'view-item')->whereHas('groups', function ($query) { |
|
166 | + return Permission::where('name', 'view-item')->whereHas('groups', function($query) { |
|
167 | 167 | $query->where('id', $this->id); |
168 | 168 | })->with('permissionable')->get()->pluck('permissionable'); |
169 | 169 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function permissionableItems() |
187 | 187 | { |
188 | - return Permission::whereHas('groups', function ($query) { |
|
188 | + return Permission::whereHas('groups', function($query) { |
|
189 | 189 | $query->where('id', $this->id); |
190 | 190 | })->with('permissionable')->get()->pluck('permissionable'); |
191 | 191 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $relationRepository = getModelRepository($relation, $model); |
72 | 72 | |
73 | 73 | if (!$keepExisting) { |
74 | - $object->$relation()->each(function ($repeaterElement) { |
|
74 | + $object->$relation()->each(function($repeaterElement) { |
|
75 | 75 | $repeaterElement->forceDelete(); |
76 | 76 | }); |
77 | 77 | } |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | |
252 | 252 | if (isset($relatedItemFormFields['medias'])) { |
253 | 253 | if (config('twill.media_library.translated_form_fields', false)) { |
254 | - Collection::make($relatedItemFormFields['medias'])->each(function ($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) { |
|
255 | - $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function ($medias, $role) use ($locale, $relation, $relationItem) { |
|
254 | + Collection::make($relatedItemFormFields['medias'])->each(function($rolesWithMedias, $locale) use (&$repeatersMedias, $relation, $relationItem) { |
|
255 | + $repeatersMedias[] = Collection::make($rolesWithMedias)->mapWithKeys(function($medias, $role) use ($locale, $relation, $relationItem) { |
|
256 | 256 | return [ |
257 | 257 | "blocks[$relation-$relationItem->id][$role][$locale]" => $medias, |
258 | 258 | ]; |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | if (isset($relatedItemFormFields['files'])) { |
269 | - Collection::make($relatedItemFormFields['files'])->each(function ($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) { |
|
270 | - $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function ($files, $role) use ($locale, $relation, $relationItem) { |
|
269 | + Collection::make($relatedItemFormFields['files'])->each(function($rolesWithFiles, $locale) use (&$repeatersFiles, $relation, $relationItem) { |
|
270 | + $repeatersFiles[] = Collection::make($rolesWithFiles)->mapWithKeys(function($files, $role) use ($locale, $relation, $relationItem) { |
|
271 | 271 | return [ |
272 | 272 | "blocks[$relation-$relationItem->id][$role][$locale]" => $files, |
273 | 273 | ]; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | protected function getRepeaters() |
328 | 328 | { |
329 | - return collect($this->repeaters)->map(function ($repeater, $key) { |
|
329 | + return collect($this->repeaters)->map(function($repeater, $key) { |
|
330 | 330 | $repeaterName = is_string($repeater) ? $repeater : $key; |
331 | 331 | return [ |
332 | 332 | 'relation' => !empty($repeater['relation']) ? $repeater['relation'] : $this->inferRelationFromRepeaterName($repeaterName), |
@@ -38,7 +38,7 @@ |
||
38 | 38 | return [ |
39 | 39 | 'name' => 'required', |
40 | 40 | 'email' => 'required|email|unique:' . config('twill.users_table', 'twill_users') . ',email,' . $this->route('user'), |
41 | - 'verify-code' => function ($attribute, $value, $fail) { |
|
41 | + 'verify-code' => function($attribute, $value, $fail) { |
|
42 | 42 | $user = Auth::guard('twill_users')->user(); |
43 | 43 | $with2faSettings = config('twill.enabled.users-2fa') && $user->id == $this->route('user'); |
44 | 44 |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | if (!function_exists('getAllModules')) { |
8 | 8 | function getAllModules() |
9 | 9 | { |
10 | - $repositories = collect(app(FileSystem::class)->glob(app_path('Repositories') . '/*.php'))->map(function ($repository) { |
|
10 | + $repositories = collect(app(FileSystem::class)->glob(app_path('Repositories') . '/*.php'))->map(function($repository) { |
|
11 | 11 | $re = "/(?<=Repositories\/).+(?=\.php)/"; |
12 | 12 | preg_match($re, $repository, $matches); |
13 | 13 | return config('twill.namespace') . "\\Repositories\\" . $matches[0]; |
14 | 14 | }); |
15 | 15 | |
16 | - $moduleRepositories = $repositories->filter(function ($repository) { |
|
16 | + $moduleRepositories = $repositories->filter(function($repository) { |
|
17 | 17 | return is_subclass_of($repository, 'A17\Twill\Repositories\ModuleRepository'); |
18 | 18 | }); |
19 | 19 | |
20 | - $modules = $moduleRepositories->map(function ($repository) { |
|
20 | + $modules = $moduleRepositories->map(function($repository) { |
|
21 | 21 | $modelName = str_replace("Repository", '', str_replace("App\\Repositories\\", "", $repository)); |
22 | 22 | return str_plural(lcfirst($modelName)); |
23 | 23 | }); |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | $permissions = []; |
96 | 96 | |
97 | 97 | if ($user->role) { |
98 | - $permissions = $user->role->permissions()->module()->pluck('name','permissionable_type')->all(); |
|
98 | + $permissions = $user->role->permissions()->module()->pluck('name', 'permissionable_type')->all(); |
|
99 | 99 | if (empty($permissions)) { |
100 | - if ($user->role->permissions()->global()->where('name', 'manage-modules')->first()){ |
|
100 | + if ($user->role->permissions()->global()->where('name', 'manage-modules')->first()) { |
|
101 | 101 | $permissions[get_class($item)] = 'manage-item'; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | // looking for group permissions belonging to the user |
107 | - foreach($user->publishedGroups as $group) { |
|
108 | - if (($permission=$group->permissions()->ofItem($item)->first())!= null) { |
|
107 | + foreach ($user->publishedGroups as $group) { |
|
108 | + if (($permission = $group->permissions()->ofItem($item)->first()) != null) { |
|
109 | 109 | if (isset($permissions[get_class($item)])) { |
110 | 110 | $scopes = Permission::available(Permission::SCOPE_ITEM); |
111 | 111 | $previous = array_search($permissions[get_class($item)], $scopes); |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | |
125 | 125 | if (isset($permissions[get_class($item)])) { |
126 | 126 | $globalPermission = str_replace('-module', '-item', $permissions[get_class($item)]); |
127 | - foreach($options as &$option) { |
|
128 | - if ($option['value'] != $globalPermission || $globalPermission=='manage-item') { |
|
127 | + foreach ($options as &$option) { |
|
128 | + if ($option['value'] != $globalPermission || $globalPermission == 'manage-item') { |
|
129 | 129 | $option['disabled'] = true; |
130 | 130 | } else { |
131 | 131 | break; |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | if (!function_exists('isUserGroupPermissionItemExists')) { |
148 | 148 | function isUserGroupPermissionItemExists($user, $item, $permission) |
149 | 149 | { |
150 | - foreach($user->publishedGroups as $group) { |
|
151 | - if (in_array($permission, $group->permissions()->ofItem($item)->get()->pluck('name')->all())){ |
|
150 | + foreach ($user->publishedGroups as $group) { |
|
151 | + if (in_array($permission, $group->permissions()->ofItem($item)->get()->pluck('name')->all())) { |
|
152 | 152 | return true; |
153 | 153 | } |
154 | 154 | } |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | if (!function_exists('isUserGroupPermissionModuleExists')) { |
161 | 161 | function isUserGroupPermissionModuleExists($user, $moduleName, $permission) |
162 | 162 | { |
163 | - foreach($user->publishedGroups as $group) { |
|
164 | - if ($moduleName=='global') { |
|
163 | + foreach ($user->publishedGroups as $group) { |
|
164 | + if ($moduleName == 'global') { |
|
165 | 165 | return $group->permissions()->global()->where('name', 'manage-modules')->exists(); |
166 | 166 | } else { |
167 | - if( in_array($permission, $group->permissions()->OfModuleName($moduleName)->get()->pluck('name')->all())){ |
|
167 | + if (in_array($permission, $group->permissions()->OfModuleName($moduleName)->get()->pluck('name')->all())) { |
|
168 | 168 | return true; |
169 | 169 | } |
170 | 170 | } |
@@ -88,7 +88,7 @@ |
||
88 | 88 | $query->where('is_superadmin', '<>', true); |
89 | 89 | $this->searchIn($query, $scopes, 'search', ['name', 'email']); |
90 | 90 | } else { |
91 | - $query->when(isset($scopes['role']), function ($query) use ($scopes) { |
|
91 | + $query->when(isset($scopes['role']), function($query) use ($scopes) { |
|
92 | 92 | $query->where('role', $scopes['role']); |
93 | 93 | }); |
94 | 94 | $query->where('role', '<>', 'SUPERADMIN'); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | if (config('twill.enabled.permissions-management') && !Auth::user()->isSuperAdmin()) { |
14 | 14 | if (config('twill.support_subdomain_admin_routing') && $activeSubdomain = config('twill.active_subdomain')) { |
15 | - foreach(Auth::user()->groups as $group) { |
|
15 | + foreach (Auth::user()->groups as $group) { |
|
16 | 16 | if (in_array($activeSubdomain, $group->subdomains_access)) { |
17 | 17 | return $next($request); |
18 | 18 | } |