@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $this->preProcess($domain, $module, $request); |
161 | 161 | |
162 | 162 | // Retrieve record |
163 | - $recordId = (int) request('id'); |
|
163 | + $recordId = (int)request('id'); |
|
164 | 164 | $modelClass = $module->model_class; |
165 | 165 | $record = $modelClass::onlyTrashed()->findOrFail($recordId); |
166 | 166 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | // Redirect to the trash list |
175 | - $route = ucroute('uccello.list', $domain, $module, ['filter' => 'trash']); |
|
175 | + $route = ucroute('uccello.list', $domain, $module, [ 'filter' => 'trash' ]); |
|
176 | 176 | return redirect($route); |
177 | 177 | } |
178 | 178 | |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | |
289 | 289 | if ($record) { |
290 | 290 | $relation = $record->$relationName(); |
291 | - if ($relatedList->type=='n-n') { |
|
291 | + if ($relatedList->type == 'n-n') { |
|
292 | 292 | $relation->attach($relatedRecordId); |
293 | - } elseif ($relatedList->type=='n-1') { |
|
293 | + } elseif ($relatedList->type == 'n-1') { |
|
294 | 294 | $relatedModelClass = $relatedList->relatedModule->model_class; |
295 | 295 | $related_record = $relatedModelClass::find($relatedRecordId); |
296 | 296 | $relation->save($related_record); |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | |
317 | 317 | // Redirect to source record if a relation was deleted |
318 | 318 | if (isset($relatedlist) && $request->input('id')) { |
319 | - $params = ['id' => $request->input('id')]; |
|
319 | + $params = [ 'id' => $request->input('id') ]; |
|
320 | 320 | |
321 | 321 | // Add tab id if defined to select it automaticaly |
322 | 322 | if ($request->input('tab')) { |
323 | - $params['tab'] = $request->input('tab'); |
|
323 | + $params[ 'tab' ] = $request->input('tab'); |
|
324 | 324 | } |
325 | 325 | // Add related list id to select the related tab automaticaly |
326 | 326 | else { |
327 | - $params['relatedlist'] = $relatedlist->id; |
|
327 | + $params[ 'relatedlist' ] = $relatedlist->id; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | $route = ucroute('uccello.detail', $domain, $relatedlist->module, $params); |
@@ -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); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | $i = 0; |
202 | 202 | foreach ($words as $w) { |
203 | - $initials .= $w[0]; |
|
203 | + $initials .= $w[ 0 ]; |
|
204 | 204 | $i++; |
205 | 205 | |
206 | 206 | if ($i === 3) { // Maximum: 3 letters |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $image = 'vendor/uccello/uccello/images/user-no-image.png'; |
222 | 222 | |
223 | 223 | if ($this->avatarType === 'gravatar') { |
224 | - $image = 'https://www.gravatar.com/avatar/' . md5($this->email) . '?d=mm'; |
|
224 | + $image = 'https://www.gravatar.com/avatar/'.md5($this->email).'?d=mm'; |
|
225 | 225 | } elseif ($this->avatarType === 'image' && !empty($this->avatar->path)) { |
226 | 226 | $image = $this->avatar->path; |
227 | 227 | } |
@@ -267,14 +267,14 @@ discard block |
||
267 | 267 | if ($withAncestors && config('uccello.roles.display_ancestors_roles')) { |
268 | 268 | $treeDomainsIds = $domain->findAncestors()->pluck('id'); |
269 | 269 | } else { |
270 | - $treeDomainsIds = collect([$domain->id]); |
|
270 | + $treeDomainsIds = collect([ $domain->id ]); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | foreach ($treeDomainsIds as $treeDomainId) { |
274 | 274 | $_domain = Domain::find($treeDomainId); |
275 | 275 | foreach ($this->privileges->where('domain_id', $_domain->id) as $privilege) { |
276 | 276 | if (!$roles->contains($privilege->role)) { |
277 | - $roles[] = $privilege->role; |
|
277 | + $roles[ ] = $privilege->role; |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | if ($withAncestors) { |
299 | 299 | $treeDomainsIds = $domain->findAncestors()->pluck('id'); |
300 | 300 | } else { |
301 | - $treeDomainsIds = collect([$domain->id]); |
|
301 | + $treeDomainsIds = collect([ $domain->id ]); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | foreach ($treeDomainsIds as $treeDomainId) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | foreach ($_privileges as $privilege) { |
314 | 314 | if (!$privileges->contains($privilege)) { |
315 | - $privileges[] = $privilege; |
|
315 | + $privileges[ ] = $privilege; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | $hasRole = false; |
369 | 369 | |
370 | - $descendants = Cache::remember('domain_' . $domain->slug . '_descendants', 600, function () use ($domain) { |
|
370 | + $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function() use ($domain) { |
|
371 | 371 | return $domain->findDescendants()->get(); |
372 | 372 | }); |
373 | 373 | |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | */ |
392 | 392 | public function capabilitiesOnModule(Domain $domain, Module $module): Collection |
393 | 393 | { |
394 | - $keyName = 'user_' . $this->id . '_' . $domain->slug . '_' . $module->name . '_capabilities'; |
|
394 | + $keyName = 'user_'.$this->id.'_'.$domain->slug.'_'.$module->name.'_capabilities'; |
|
395 | 395 | |
396 | - return Cache::remember($keyName, 600, function () use ($domain, $module) { |
|
396 | + return Cache::remember($keyName, 600, function() use ($domain, $module) { |
|
397 | 397 | $capabilities = collect(); |
398 | 398 | |
399 | 399 | // Get the domain and all its parents |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | $domain = Domain::first(); |
445 | 445 | } |
446 | 446 | |
447 | - $keyName = 'user_' . $this->id . '_' . $domain->slug . '_can_access_to_settings_panel'; |
|
447 | + $keyName = 'user_'.$this->id.'_'.$domain->slug.'_can_access_to_settings_panel'; |
|
448 | 448 | |
449 | - return Cache::remember($keyName, 600, function () use ($domain) { |
|
449 | + return Cache::remember($keyName, 600, function() use ($domain) { |
|
450 | 450 | |
451 | 451 | $hasCapability = false; |
452 | 452 | |
@@ -598,8 +598,8 @@ discard block |
||
598 | 598 | { |
599 | 599 | // Use cache |
600 | 600 | $allowedGroups = Cache::rememberForever( |
601 | - 'allowed_groups_for_' . ($this->is_admin ? 'admin' : $this->getKey()), |
|
602 | - function () { |
|
601 | + 'allowed_groups_for_'.($this->is_admin ? 'admin' : $this->getKey()), |
|
602 | + function() { |
|
603 | 603 | return $this->getAllowedGroupUuidsProcess(); |
604 | 604 | } |
605 | 605 | ); |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | { |
612 | 612 | // Use cache |
613 | 613 | $allowedGroupsAndUsers = Cache::rememberForever( |
614 | - 'allowed_group_users_for_' . |
|
615 | - 'd_' . $domain->getKey() . '_' . |
|
616 | - ($addUsers ? 'u_' : '') . |
|
614 | + 'allowed_group_users_for_'. |
|
615 | + 'd_'.$domain->getKey().'_'. |
|
616 | + ($addUsers ? 'u_' : ''). |
|
617 | 617 | ($this->is_admin ? 'admin' : $this->getKey()), |
618 | - function () use ($domain, $addUsers) { |
|
618 | + function() use ($domain, $addUsers) { |
|
619 | 619 | return $this->getAllowedGroupsAndUsersProcess($domain, $addUsers); |
620 | 620 | } |
621 | 621 | ); |
@@ -625,16 +625,16 @@ discard block |
||
625 | 625 | |
626 | 626 | protected function getAllowedGroupUuidsProcess() |
627 | 627 | { |
628 | - $allowedUserUuids = collect([$this->uuid]); |
|
628 | + $allowedUserUuids = collect([ $this->uuid ]); |
|
629 | 629 | |
630 | 630 | if ($this->is_admin) { |
631 | 631 | $groups = Group::all(); |
632 | 632 | } else { |
633 | - $groups = []; |
|
634 | - $users = []; |
|
633 | + $groups = [ ]; |
|
634 | + $users = [ ]; |
|
635 | 635 | |
636 | 636 | foreach ($this->groups as $group) { |
637 | - $groups[$group->uuid] = $group; |
|
637 | + $groups[ $group->uuid ] = $group; |
|
638 | 638 | }; |
639 | 639 | |
640 | 640 | $this->addRecursiveChildrenGroups($groups, $users, $groups, false); |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | } |
644 | 644 | |
645 | 645 | foreach ($groups as $uuid => $group) { |
646 | - $allowedUserUuids[] = $uuid; |
|
646 | + $allowedUserUuids[ ] = $uuid; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | return $allowedUserUuids; |
@@ -652,18 +652,18 @@ discard block |
||
652 | 652 | protected function addRecursiveChildrenGroups(&$groups, &$users, $searchGroups, $addUsers = false) |
653 | 653 | { |
654 | 654 | foreach ($searchGroups as $uuid => $searchGroup) { |
655 | - $searchChildrenGroups = []; |
|
655 | + $searchChildrenGroups = [ ]; |
|
656 | 656 | |
657 | 657 | foreach ($searchGroup->childrenGroups as $childrenGroup) { |
658 | - if (empty($groups[$childrenGroup->uuid])) { |
|
659 | - $groups[$childrenGroup->uuid] = $childrenGroup; |
|
660 | - $searchChildrenGroups[$childrenGroup->uuid] = $childrenGroup; |
|
658 | + if (empty($groups[ $childrenGroup->uuid ])) { |
|
659 | + $groups[ $childrenGroup->uuid ] = $childrenGroup; |
|
660 | + $searchChildrenGroups[ $childrenGroup->uuid ] = $childrenGroup; |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | if ($addUsers) { |
664 | 664 | foreach ($childrenGroup->users as $user) { |
665 | - if (empty($users[$user->uuid])) { |
|
666 | - $users[$user->uuid] = $user; |
|
665 | + if (empty($users[ $user->uuid ])) { |
|
666 | + $users[ $user->uuid ] = $user; |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | } |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | |
676 | 676 | protected function getAllowedGroupsAndUsersProcess(Domain $domain, $addUsers = true) |
677 | 677 | { |
678 | - $allowedUserUuids = collect([[ |
|
678 | + $allowedUserUuids = collect([ [ |
|
679 | 679 | 'uuid' => $this->uuid, |
680 | 680 | 'recordLabel' => uctrans('me', $this->module) |
681 | - ]]); |
|
681 | + ] ]); |
|
682 | 682 | |
683 | 683 | // if ($this->is_admin) { |
684 | 684 | $groups = Group::inDomain($domain)->orderBy('name')->get(); |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | // } |
708 | 708 | |
709 | 709 | foreach ($groups as $uuid => $group) { |
710 | - $allowedUserUuids[] = [ |
|
710 | + $allowedUserUuids[ ] = [ |
|
711 | 711 | 'uuid' => $group->uuid, |
712 | 712 | 'recordLabel' => $group->recordLabel |
713 | 713 | ]; |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | foreach ($users as $uuid => $user) { |
717 | 717 | if ($user->getKey() != $this->getKey()) { |
718 | - $allowedUserUuids[] = [ |
|
718 | + $allowedUserUuids[ ] = [ |
|
719 | 719 | 'uuid' => $user->uuid, |
720 | 720 | 'recordLabel' => $user->recordLabel |
721 | 721 | ]; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | // 'data-live-search' => 'true', |
55 | 55 | // 'data-abs-ajax-url' => ucroute('uccello.autocomplete', $domain, $relatedModule) |
56 | 56 | ], |
57 | - 'query_builder' => function ($relatedRecord) use ($domain, $record) { |
|
57 | + 'query_builder' => function($relatedRecord) use ($domain, $record) { |
|
58 | 58 | // TODO: Filter depending users profiles... |
59 | 59 | return Auth::user()->getAllowedGroupsAndUsers($domain, true); |
60 | 60 | }, |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function addConditionToSearchQuery(Builder $query, Field $field, $value) : Builder |
111 | 111 | { |
112 | - $query->where(function ($query) use($field, $value) { |
|
113 | - foreach ((array) $value as $_value) { |
|
112 | + $query->where(function($query) use($field, $value) { |
|
113 | + foreach ((array)$value as $_value) { |
|
114 | 114 | // Replace me by connected user's id |
115 | 115 | if ($_value === 'me') { |
116 | 116 | $_value = Auth::user()->uuid; |
@@ -3,9 +3,9 @@ |
||
3 | 3 | <?php |
4 | 4 | $autocompleteSearch = false; |
5 | 5 | |
6 | - $entities = []; |
|
6 | + $entities = [ ]; |
|
7 | 7 | |
8 | - if (isset($column['data']->autocomplete_search) && $column['data']->autocomplete_search === true) { |
|
8 | + if (isset($column[ 'data' ]->autocomplete_search) && $column[ 'data' ]->autocomplete_search === true) { |
|
9 | 9 | $autocompleteSearch = true; |
10 | 10 | } else { |
11 | 11 | $entities = auth()->user()->getAllowedGroupsAndUsers($domain, false); |