@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public function getFormattedValueToDisplay(Field $field, $record) : string |
| 76 | 76 | { |
| 77 | 77 | if (isset($field->data->multiple) && $field->data->multiple === true && !empty($record->{$field->column})) { |
| 78 | - $values = []; |
|
| 78 | + $values = [ ]; |
|
| 79 | 79 | |
| 80 | 80 | $fieldValues = json_decode($record->{$field->column}); |
| 81 | 81 | if (is_array($fieldValues)) { |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | continue; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $values[] = uctrans($value, $field->module); |
|
| 87 | + $values[ ] = uctrans($value, $field->module); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $value = implode(', ', $values); |
| 92 | 92 | } else { |
| 93 | - $value = parent::getFormattedValueToDisplay($field, $record); |
|
| 93 | + $value = parent::getFormattedValueToDisplay($field, $record); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | return $value; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $roots = collect(); |
| 61 | 61 | foreach ($rootRecords as $record) { |
| 62 | - $roots[] = $this->getFormattedRecordToAdd($record); |
|
| 62 | + $roots[ ] = $this->getFormattedRecordToAdd($record); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return $roots; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $children = collect(); |
| 86 | 86 | if ($parentRecord) { |
| 87 | 87 | foreach ($parentRecord->children()->get() as $record) { |
| 88 | - $children[] = $this->getFormattedRecordToAdd($record); |
|
| 88 | + $children[ ] = $this->getFormattedRecordToAdd($record); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | @if ($value) |
| 17 | 17 | <?php |
| 18 | 18 | $valueParts = explode(';', $value); |
| 19 | - $fileName = $valueParts[0]; |
|
| 19 | + $fileName = $valueParts[ 0 ]; |
|
| 20 | 20 | ?> |
| 21 | 21 | <div class="input-field current-file"> |
| 22 | 22 | <div class="file-container"> |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | foreach ($treeDomainsIds as $treeDomainId) { |
| 45 | 45 | $_domain = Domain::find($treeDomainId); |
| 46 | 46 | foreach ($_domain->roles as $role) { |
| 47 | - $roleName = $_domain->id === $domain->id ? $role->name : $_domain->name . ' > ' . $role->name; |
|
| 47 | + $roleName = $_domain->id === $domain->id ? $role->name : $_domain->name.' > '.$role->name; |
|
| 48 | 48 | $roles[ $role->id ] = $roleName; |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -176,8 +176,8 @@ |
||
| 176 | 176 | } |
| 177 | 177 | // Several routes |
| 178 | 178 | elseif (is_array($this->data->menu)) { |
| 179 | - if (!empty($this->data->menu[0]->route)) { |
|
| 180 | - $defaultRoute = $this->data->menu[0]->route; |
|
| 179 | + if (!empty($this->data->menu[ 0 ]->route)) { |
|
| 180 | + $defaultRoute = $this->data->menu[ 0 ]->route; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $builder->whereIn($model->getTable().'.assigned_user_id', $user->getAllowedGroupUuids()); |
| 28 | 28 | |
| 29 | 29 | // Records assigned to an user with roles subordonate to the roles of the user |
| 30 | - $builder->orWhereIn($model->getTable().'.assigned_user_id', function ($query) use ($user) { |
|
| 30 | + $builder->orWhereIn($model->getTable().'.assigned_user_id', function($query) use ($user) { |
|
| 31 | 31 | $entityTable = with(new Entity)->getTable(); |
| 32 | 32 | $privilegesTable = env('UCCELLO_TABLE_PREFIX', 'uccello_').'privileges'; |
| 33 | 33 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | $query->select($entityTable.'.id') |
| 38 | 38 | ->from($entityTable) |
| 39 | - ->join($privilegesTable, function ($join) use($entityTable, $privilegesTable, $subordonateRolesIds) { |
|
| 39 | + ->join($privilegesTable, function($join) use($entityTable, $privilegesTable, $subordonateRolesIds) { |
|
| 40 | 40 | $join->on("$privilegesTable.user_id", '=', $entityTable.'.record_id') |
| 41 | 41 | ->whereIn("$privilegesTable.role_id", $subordonateRolesIds); |
| 42 | 42 | }) |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // Records created by the user |
| 47 | 47 | if (!empty($model->module)) { |
| 48 | - $builder->orWhereIn($model->getTable().'.'.$model->getKeyName(), function ($query) use($model) { |
|
| 48 | + $builder->orWhereIn($model->getTable().'.'.$model->getKeyName(), function($query) use($model) { |
|
| 49 | 49 | $query->select('record_id') |
| 50 | 50 | ->from(with(new Entity)->getTable()) |
| 51 | 51 | ->where('module_id', $model->module->id ?? null) |
@@ -74,9 +74,9 @@ |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | // Redirect if form not valid |
| 77 | - if (! $form->isValid()) { |
|
| 77 | + if (!$form->isValid()) { |
|
| 78 | 78 | ucnotify(uctrans('notification.form.not_valid', $module), 'error'); |
| 79 | - $response = redirect(route('uccello.popup.edit', ['domain' => $domain->slug, 'module' => $module->name])); |
|
| 79 | + $response = redirect(route('uccello.popup.edit', [ 'domain' => $domain->slug, 'module' => $module->name ])); |
|
| 80 | 80 | $response = $response->withErrors($form->getErrors(), $form->getErrorBag())->withInput(); |
| 81 | 81 | return $response; |
| 82 | 82 | } |
@@ -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 | ]; |