@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // Create uuid after save |
31 | - static::created(function ($model) { |
|
31 | + static::created(function($model) { |
|
32 | 32 | $module = Module::where('model_class', get_class($model))->first(); |
33 | 33 | if ($module) { |
34 | 34 | Entity::create([ |
35 | - 'id' => (string) Str::uuid(), |
|
35 | + 'id' => (string)Str::uuid(), |
|
36 | 36 | 'module_id' => $module->id, |
37 | 37 | 'record_id' => $model->getKey(), |
38 | 38 | 'creator_id' => auth()->id(), |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | }); |
42 | 42 | |
43 | 43 | // Delete uuid after forced delete |
44 | - static::deleted(function ($model) { |
|
44 | + static::deleted(function($model) { |
|
45 | 45 | if (!empty($model->uuid) && (!method_exists($model, 'isForceDeleting') || $model->isForceDeleting() === true)) { |
46 | 46 | $entity = Entity::find($model->uuid); |
47 | 47 | if ($entity) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | public function initializeUccelloModule() |
55 | 55 | { |
56 | - $this->appends = array_merge($this->appends, ['recordLabel','uuid']); |
|
56 | + $this->appends = array_merge($this->appends, [ 'recordLabel', 'uuid' ]); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | protected static function isFilteredByUser() |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | |
86 | 86 | protected static function getModuleFromClass($className) |
87 | 87 | { |
88 | - $modules = Cache::rememberForever('modules_by_model_class', function () { |
|
88 | + $modules = Cache::rememberForever('modules_by_model_class', function() { |
|
89 | 89 | $modulesGroupedByModelClass = collect(); |
90 | - Module::all()->map(function ($item) use ($modulesGroupedByModelClass) { |
|
91 | - $modulesGroupedByModelClass[$item->model_class] = $item; |
|
90 | + Module::all()->map(function($item) use ($modulesGroupedByModelClass) { |
|
91 | + $modulesGroupedByModelClass[ $item->model_class ] = $item; |
|
92 | 92 | return $modulesGroupedByModelClass; |
93 | 93 | }); |
94 | 94 | return $modulesGroupedByModelClass; |
95 | 95 | }); |
96 | - return $modules[(string) $className] ?? null; |
|
96 | + return $modules[ (string)$className ] ?? null; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public function getUuidAttribute() |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if (!empty($domain) && Schema::hasColumn($this->table, 'domain_id')) { |
155 | 155 | // Activate descendant view if the user is allowed |
156 | 156 | if (Auth::user() && Auth::user()->canSeeDescendantsRecords($domain) && $withDescendants) { |
157 | - $query->whereIn('domain_id', function ($query) use ($domain) { |
|
157 | + $query->whereIn('domain_id', function($query) use ($domain) { |
|
158 | 158 | $query->select('id') |
159 | 159 | ->from((new Domain)->getTable()) |
160 | 160 | ->where('path', 'like', $domain->id.'%') |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @var array |
33 | 33 | */ |
34 | - protected $dates = ['deleted_at']; |
|
34 | + protected $dates = [ 'deleted_at' ]; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * The attributes that should be casted to native types. |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | // Check if user is admin or if he has at least a role on the domain |
110 | 110 | // or on descendants domains if withDescendants option is on |
111 | 111 | $builder->where('domain_id', $domain->id) |
112 | - ->orWhereIn($this->getKeyName(), function ($query) use ($domain, $withDescendants) { |
|
113 | - $privilegesTable = env('UCCELLO_TABLE_PREFIX', 'uccello_') . 'privileges'; |
|
112 | + ->orWhereIn($this->getKeyName(), function($query) use ($domain, $withDescendants) { |
|
113 | + $privilegesTable = env('UCCELLO_TABLE_PREFIX', 'uccello_').'privileges'; |
|
114 | 114 | |
115 | 115 | $query->select('user_id') |
116 | 116 | ->from($privilegesTable); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | if (Auth::user() && Auth::user()->canSeeDescendantsRecords($domain) && $withDescendants) { |
127 | - $query->orWhereIn('domain_id', function ($query) use ($domain) { |
|
127 | + $query->orWhereIn('domain_id', function($query) use ($domain) { |
|
128 | 128 | $query->select('id') |
129 | 129 | ->from((new Domain)->getTable()) |
130 | 130 | ->where('path', 'like', $domain->id.'%') |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | $i = 0; |
206 | 206 | foreach ($words as $w) { |
207 | - $initials .= $w[0]; |
|
207 | + $initials .= $w[ 0 ]; |
|
208 | 208 | $i++; |
209 | 209 | |
210 | 210 | if ($i === 3) { // Maximum: 3 letters |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $image = 'vendor/uccello/uccello/images/user-no-image.png'; |
226 | 226 | |
227 | 227 | if ($this->avatarType === 'gravatar') { |
228 | - $image = 'https://www.gravatar.com/avatar/' . md5($this->email) . '?d=mm'; |
|
228 | + $image = 'https://www.gravatar.com/avatar/'.md5($this->email).'?d=mm'; |
|
229 | 229 | } elseif ($this->avatarType === 'image' && !empty($this->avatar->path)) { |
230 | 230 | $image = $this->avatar->path; |
231 | 231 | } |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | if ($withAncestors && config('uccello.roles.display_ancestors_roles')) { |
272 | 272 | $treeDomainsIds = $domain->findAncestors()->pluck('id'); |
273 | 273 | } else { |
274 | - $treeDomainsIds = collect([$domain->id]); |
|
274 | + $treeDomainsIds = collect([ $domain->id ]); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | foreach ($treeDomainsIds as $treeDomainId) { |
278 | 278 | $_domain = Domain::find($treeDomainId); |
279 | 279 | foreach ($this->privileges->where('domain_id', $_domain->id) as $privilege) { |
280 | 280 | if (!$roles->contains($privilege->role)) { |
281 | - $roles[] = $privilege->role; |
|
281 | + $roles[ ] = $privilege->role; |
|
282 | 282 | } |
283 | 283 | } |
284 | 284 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | if ($withAncestors) { |
303 | 303 | $treeDomainsIds = $domain->findAncestors()->pluck('id'); |
304 | 304 | } else { |
305 | - $treeDomainsIds = collect([$domain->id]); |
|
305 | + $treeDomainsIds = collect([ $domain->id ]); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | foreach ($treeDomainsIds as $treeDomainId) { |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | |
317 | 317 | foreach ($_privileges as $privilege) { |
318 | 318 | if (!$privileges->contains($privilege)) { |
319 | - $privileges[] = $privilege; |
|
319 | + $privileges[ ] = $privilege; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | $hasRole = false; |
373 | 373 | |
374 | - $descendants = Cache::remember('domain_' . $domain->slug . '_descendants', 600, function () use ($domain) { |
|
374 | + $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function() use ($domain) { |
|
375 | 375 | return $domain->findDescendants()->get(); |
376 | 376 | }); |
377 | 377 | |
@@ -395,9 +395,9 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function capabilitiesOnModule(Domain $domain, Module $module): Collection |
397 | 397 | { |
398 | - $keyName = 'user_' . $this->id . '_' . $domain->slug . '_' . $module->name . '_capabilities'; |
|
398 | + $keyName = 'user_'.$this->id.'_'.$domain->slug.'_'.$module->name.'_capabilities'; |
|
399 | 399 | |
400 | - return Cache::remember($keyName, 600, function () use ($domain, $module) { |
|
400 | + return Cache::remember($keyName, 600, function() use ($domain, $module) { |
|
401 | 401 | $capabilities = collect(); |
402 | 402 | |
403 | 403 | // Get the domain and all its parents |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | $domain = Domain::first(); |
449 | 449 | } |
450 | 450 | |
451 | - $keyName = 'user_' . $this->id . '_' . $domain->slug . '_can_access_to_settings_panel'; |
|
451 | + $keyName = 'user_'.$this->id.'_'.$domain->slug.'_can_access_to_settings_panel'; |
|
452 | 452 | |
453 | - return Cache::remember($keyName, 600, function () use ($domain) { |
|
453 | + return Cache::remember($keyName, 600, function() use ($domain) { |
|
454 | 454 | |
455 | 455 | $hasCapability = false; |
456 | 456 | |
@@ -602,8 +602,8 @@ discard block |
||
602 | 602 | { |
603 | 603 | // Use cache |
604 | 604 | $allowedGroups = Cache::rememberForever( |
605 | - 'allowed_groups_for_' . ($this->is_admin ? 'admin' : $this->getKey()), |
|
606 | - function () { |
|
605 | + 'allowed_groups_for_'.($this->is_admin ? 'admin' : $this->getKey()), |
|
606 | + function() { |
|
607 | 607 | return $this->getAllowedGroupUuidsProcess(); |
608 | 608 | } |
609 | 609 | ); |
@@ -615,11 +615,11 @@ discard block |
||
615 | 615 | { |
616 | 616 | // Use cache |
617 | 617 | $allowedGroupsAndUsers = Cache::rememberForever( |
618 | - 'allowed_group_users_for_' . |
|
619 | - 'd_' . $domain->getKey() . '_' . |
|
620 | - ($addUsers ? 'u_' : '') . |
|
618 | + 'allowed_group_users_for_'. |
|
619 | + 'd_'.$domain->getKey().'_'. |
|
620 | + ($addUsers ? 'u_' : ''). |
|
621 | 621 | ($this->is_admin ? 'admin' : $this->getKey()), |
622 | - function () use ($domain, $addUsers) { |
|
622 | + function() use ($domain, $addUsers) { |
|
623 | 623 | return $this->getAllowedGroupsAndUsersProcess($domain, $addUsers); |
624 | 624 | } |
625 | 625 | ); |
@@ -629,16 +629,16 @@ discard block |
||
629 | 629 | |
630 | 630 | protected function getAllowedGroupUuidsProcess() |
631 | 631 | { |
632 | - $allowedUserUuids = collect([$this->uuid]); |
|
632 | + $allowedUserUuids = collect([ $this->uuid ]); |
|
633 | 633 | |
634 | 634 | if ($this->is_admin) { |
635 | 635 | $groups = Group::all(); |
636 | 636 | } else { |
637 | - $groups = []; |
|
638 | - $users = []; |
|
637 | + $groups = [ ]; |
|
638 | + $users = [ ]; |
|
639 | 639 | |
640 | 640 | foreach ($this->groups as $group) { |
641 | - $groups[$group->uuid] = $group; |
|
641 | + $groups[ $group->uuid ] = $group; |
|
642 | 642 | }; |
643 | 643 | |
644 | 644 | $this->addRecursiveChildrenGroups($groups, $users, $groups, false); |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | } |
648 | 648 | |
649 | 649 | foreach ($groups as $uuid => $group) { |
650 | - $allowedUserUuids[] = $uuid; |
|
650 | + $allowedUserUuids[ ] = $uuid; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | return $allowedUserUuids; |
@@ -656,18 +656,18 @@ discard block |
||
656 | 656 | protected function addRecursiveChildrenGroups(&$groups, &$users, $searchGroups, $addUsers = false) |
657 | 657 | { |
658 | 658 | foreach ($searchGroups as $uuid => $searchGroup) { |
659 | - $searchChildrenGroups = []; |
|
659 | + $searchChildrenGroups = [ ]; |
|
660 | 660 | |
661 | 661 | foreach ($searchGroup->childrenGroups as $childrenGroup) { |
662 | - if (empty($groups[$childrenGroup->uuid])) { |
|
663 | - $groups[$childrenGroup->uuid] = $childrenGroup; |
|
664 | - $searchChildrenGroups[$childrenGroup->uuid] = $childrenGroup; |
|
662 | + if (empty($groups[ $childrenGroup->uuid ])) { |
|
663 | + $groups[ $childrenGroup->uuid ] = $childrenGroup; |
|
664 | + $searchChildrenGroups[ $childrenGroup->uuid ] = $childrenGroup; |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($addUsers) { |
668 | 668 | foreach ($childrenGroup->users as $user) { |
669 | - if (empty($users[$user->uuid])) { |
|
670 | - $users[$user->uuid] = $user; |
|
669 | + if (empty($users[ $user->uuid ])) { |
|
670 | + $users[ $user->uuid ] = $user; |
|
671 | 671 | } |
672 | 672 | } |
673 | 673 | } |
@@ -679,10 +679,10 @@ discard block |
||
679 | 679 | |
680 | 680 | protected function getAllowedGroupsAndUsersProcess(Domain $domain, $addUsers = true) |
681 | 681 | { |
682 | - $allowedUserUuids = collect([[ |
|
682 | + $allowedUserUuids = collect([ [ |
|
683 | 683 | 'uuid' => $this->uuid, |
684 | 684 | 'recordLabel' => uctrans('me', $this->module) |
685 | - ]]); |
|
685 | + ] ]); |
|
686 | 686 | |
687 | 687 | // if ($this->is_admin) { |
688 | 688 | $groups = Group::inDomain($domain)->orderBy('name')->get(); |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | // } |
712 | 712 | |
713 | 713 | foreach ($groups as $uuid => $group) { |
714 | - $allowedUserUuids[] = [ |
|
714 | + $allowedUserUuids[ ] = [ |
|
715 | 715 | 'uuid' => $group->uuid, |
716 | 716 | 'recordLabel' => $group->recordLabel |
717 | 717 | ]; |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | |
720 | 720 | foreach ($users as $uuid => $user) { |
721 | 721 | if ($user->getKey() != $this->getKey()) { |
722 | - $allowedUserUuids[] = [ |
|
722 | + $allowedUserUuids[ ] = [ |
|
723 | 723 | 'uuid' => $user->uuid, |
724 | 724 | 'recordLabel' => $user->recordLabel |
725 | 725 | ]; |