@@ -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() |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $module = $this->module; |
104 | 104 | |
105 | 105 | if ($module) { |
106 | - return Cache::rememberForever('uuid_'.$module->getKey().'_'.$this->getKey(), function () use ($module) { |
|
106 | + return Cache::rememberForever('uuid_'.$module->getKey().'_'.$this->getKey(), function() use ($module) { |
|
107 | 107 | $entity = Entity::where('module_id', $module->getKey()) |
108 | 108 | ->where('record_id', $this->getKey()) |
109 | 109 | ->first(); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | if (!empty($domain) && Schema::hasColumn($this->table, 'domain_id')) { |
160 | 160 | // Activate descendant view if the user is allowed |
161 | 161 | if (Auth::user() && Auth::user()->canSeeDescendantsRecords($domain) && $withDescendants) { |
162 | - $query->whereIn('domain_id', function ($query) use ($domain) { |
|
162 | + $query->whereIn('domain_id', function($query) use ($domain) { |
|
163 | 163 | $query->select('id') |
164 | 164 | ->from((new Domain)->getTable()) |
165 | 165 | ->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.'/%') |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $i = 0; |
207 | 207 | foreach ($words as $w) { |
208 | - $initials .= $w[0]; |
|
208 | + $initials .= $w[ 0 ]; |
|
209 | 209 | $i++; |
210 | 210 | |
211 | 211 | if ($i === 3) { // Maximum: 3 letters |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $image = 'vendor/uccello/uccello/images/user-no-image.png'; |
227 | 227 | |
228 | 228 | if ($this->avatarType === 'gravatar') { |
229 | - $image = 'https://www.gravatar.com/avatar/' . md5($this->email) . '?d=mm'; |
|
229 | + $image = 'https://www.gravatar.com/avatar/'.md5($this->email).'?d=mm'; |
|
230 | 230 | } elseif ($this->avatarType === 'image' && !empty($this->avatar->path)) { |
231 | 231 | $image = $this->avatar->path; |
232 | 232 | } |
@@ -272,14 +272,14 @@ discard block |
||
272 | 272 | if ($withAncestors && config('uccello.roles.display_ancestors_roles')) { |
273 | 273 | $treeDomainsIds = $domain->findAncestors()->pluck('id'); |
274 | 274 | } else { |
275 | - $treeDomainsIds = collect([$domain->id]); |
|
275 | + $treeDomainsIds = collect([ $domain->id ]); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | foreach ($treeDomainsIds as $treeDomainId) { |
279 | 279 | $_domain = Domain::find($treeDomainId); |
280 | 280 | foreach ($this->privileges->where('domain_id', $_domain->id) as $privilege) { |
281 | 281 | if (!$roles->contains($privilege->role)) { |
282 | - $roles[] = $privilege->role; |
|
282 | + $roles[ ] = $privilege->role; |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | if ($withAncestors) { |
304 | 304 | $treeDomainsIds = $domain->findAncestors()->pluck('id'); |
305 | 305 | } else { |
306 | - $treeDomainsIds = collect([$domain->id]); |
|
306 | + $treeDomainsIds = collect([ $domain->id ]); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | foreach ($treeDomainsIds as $treeDomainId) { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | foreach ($_privileges as $privilege) { |
319 | 319 | if (!$privileges->contains($privilege)) { |
320 | - $privileges[] = $privilege; |
|
320 | + $privileges[ ] = $privilege; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | $hasRole = false; |
374 | 374 | |
375 | - $descendants = Cache::remember('domain_' . $domain->slug . '_descendants', 600, function () use ($domain) { |
|
375 | + $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function() use ($domain) { |
|
376 | 376 | return $domain->findDescendants()->get(); |
377 | 377 | }); |
378 | 378 | |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function capabilitiesOnModule(Domain $domain, Module $module): Collection |
398 | 398 | { |
399 | - $keyName = 'user_' . $this->id . '_' . $domain->slug . '_' . $module->name . '_capabilities'; |
|
399 | + $keyName = 'user_'.$this->id.'_'.$domain->slug.'_'.$module->name.'_capabilities'; |
|
400 | 400 | |
401 | - return Cache::remember($keyName, 600, function () use ($domain, $module) { |
|
401 | + return Cache::remember($keyName, 600, function() use ($domain, $module) { |
|
402 | 402 | $capabilities = collect(); |
403 | 403 | |
404 | 404 | // Get the domain and all its parents |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | $domain = Domain::first(); |
450 | 450 | } |
451 | 451 | |
452 | - $keyName = 'user_' . $this->id . '_' . $domain->slug . '_can_access_to_settings_panel'; |
|
452 | + $keyName = 'user_'.$this->id.'_'.$domain->slug.'_can_access_to_settings_panel'; |
|
453 | 453 | |
454 | - return Cache::remember($keyName, 600, function () use ($domain) { |
|
454 | + return Cache::remember($keyName, 600, function() use ($domain) { |
|
455 | 455 | |
456 | 456 | $hasCapability = false; |
457 | 457 | |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | { |
604 | 604 | // Use cache |
605 | 605 | $allowedGroups = Cache::rememberForever( |
606 | - 'allowed_groups_for_' . ($this->is_admin ? 'admin' : $this->getKey()), |
|
607 | - function () { |
|
606 | + 'allowed_groups_for_'.($this->is_admin ? 'admin' : $this->getKey()), |
|
607 | + function() { |
|
608 | 608 | return $this->getAllowedGroupUuidsProcess(); |
609 | 609 | } |
610 | 610 | ); |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | { |
617 | 617 | // Use cache |
618 | 618 | $allowedGroupsAndUsers = Cache::rememberForever( |
619 | - 'allowed_group_users_for_' . |
|
620 | - 'd_' . $domain->getKey() . '_' . |
|
621 | - ($addUsers ? 'u_' : '') . |
|
619 | + 'allowed_group_users_for_'. |
|
620 | + 'd_'.$domain->getKey().'_'. |
|
621 | + ($addUsers ? 'u_' : ''). |
|
622 | 622 | ($this->is_admin ? 'admin' : $this->getKey()), |
623 | - function () use ($domain, $addUsers) { |
|
623 | + function() use ($domain, $addUsers) { |
|
624 | 624 | return $this->getAllowedGroupsAndUsersProcess($domain, $addUsers); |
625 | 625 | } |
626 | 626 | ); |
@@ -630,16 +630,16 @@ discard block |
||
630 | 630 | |
631 | 631 | protected function getAllowedGroupUuidsProcess() |
632 | 632 | { |
633 | - $allowedUserUuids = collect([$this->uuid]); |
|
633 | + $allowedUserUuids = collect([ $this->uuid ]); |
|
634 | 634 | |
635 | 635 | if ($this->is_admin) { |
636 | 636 | $groups = Group::all(); |
637 | 637 | } else { |
638 | - $groups = []; |
|
639 | - $users = []; |
|
638 | + $groups = [ ]; |
|
639 | + $users = [ ]; |
|
640 | 640 | |
641 | 641 | foreach ($this->groups as $group) { |
642 | - $groups[$group->uuid] = $group; |
|
642 | + $groups[ $group->uuid ] = $group; |
|
643 | 643 | }; |
644 | 644 | |
645 | 645 | $this->addRecursiveChildrenGroups($groups, $users, $groups, false); |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | } |
649 | 649 | |
650 | 650 | foreach ($groups as $uuid => $group) { |
651 | - $allowedUserUuids[] = $uuid; |
|
651 | + $allowedUserUuids[ ] = $uuid; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | return $allowedUserUuids; |
@@ -657,18 +657,18 @@ discard block |
||
657 | 657 | protected function addRecursiveChildrenGroups(&$groups, &$users, $searchGroups, $addUsers = false) |
658 | 658 | { |
659 | 659 | foreach ($searchGroups as $uuid => $searchGroup) { |
660 | - $searchChildrenGroups = []; |
|
660 | + $searchChildrenGroups = [ ]; |
|
661 | 661 | |
662 | 662 | foreach ($searchGroup->childrenGroups as $childrenGroup) { |
663 | - if (empty($groups[$childrenGroup->uuid])) { |
|
664 | - $groups[$childrenGroup->uuid] = $childrenGroup; |
|
665 | - $searchChildrenGroups[$childrenGroup->uuid] = $childrenGroup; |
|
663 | + if (empty($groups[ $childrenGroup->uuid ])) { |
|
664 | + $groups[ $childrenGroup->uuid ] = $childrenGroup; |
|
665 | + $searchChildrenGroups[ $childrenGroup->uuid ] = $childrenGroup; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | if ($addUsers) { |
669 | 669 | foreach ($childrenGroup->users as $user) { |
670 | - if (empty($users[$user->uuid])) { |
|
671 | - $users[$user->uuid] = $user; |
|
670 | + if (empty($users[ $user->uuid ])) { |
|
671 | + $users[ $user->uuid ] = $user; |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |
@@ -680,10 +680,10 @@ discard block |
||
680 | 680 | |
681 | 681 | protected function getAllowedGroupsAndUsersProcess(Domain $domain, $addUsers = true) |
682 | 682 | { |
683 | - $allowedUserUuids = collect([[ |
|
683 | + $allowedUserUuids = collect([ [ |
|
684 | 684 | 'uuid' => $this->uuid, |
685 | 685 | 'recordLabel' => uctrans('me', $this->module) |
686 | - ]]); |
|
686 | + ] ]); |
|
687 | 687 | |
688 | 688 | // if ($this->is_admin) { |
689 | 689 | $groups = Group::inDomain($domain)->orderBy('name')->get(); |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | // } |
713 | 713 | |
714 | 714 | foreach ($groups as $uuid => $group) { |
715 | - $allowedUserUuids[] = [ |
|
715 | + $allowedUserUuids[ ] = [ |
|
716 | 716 | 'uuid' => $group->uuid, |
717 | 717 | 'recordLabel' => $group->recordLabel |
718 | 718 | ]; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | |
721 | 721 | foreach ($users as $uuid => $user) { |
722 | 722 | if ($user->getKey() != $this->getKey()) { |
723 | - $allowedUserUuids[] = [ |
|
723 | + $allowedUserUuids[ ] = [ |
|
724 | 724 | 'uuid' => $user->uuid, |
725 | 725 | 'recordLabel' => $user->recordLabel |
726 | 726 | ]; |