@@ -123,7 +123,7 @@ |
||
123 | 123 | protected function isEmptyOrNotEmptySearchQuery(Builder &$query, Field $field, $value): bool |
124 | 124 | { |
125 | 125 | if ($value == uctrans('filter.search_flag.empty', $field->module)) { |
126 | - $query->where(function ($q) use ($field) { |
|
126 | + $query->where(function($q) use ($field) { |
|
127 | 127 | $q->whereNull($field->column) |
128 | 128 | ->orWhere($field->column, '=', ''); |
129 | 129 | }); |
@@ -130,7 +130,7 @@ |
||
130 | 130 | if (method_exists($modelClass, 'getSearchResult') && property_exists($modelClass, 'searchableColumns')) { |
131 | 131 | // Search related records and get all ids |
132 | 132 | $searchResults = new Search(); |
133 | - $searchResults->registerModel($modelClass, (array) (new $modelClass)->searchableColumns); |
|
133 | + $searchResults->registerModel($modelClass, (array)(new $modelClass)->searchableColumns); |
|
134 | 134 | $recordIds = $searchResults->search($value)->pluck('searchable.id'); |
135 | 135 | |
136 | 136 | // Search records linked to record ids got previously |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ]; |
59 | 59 | |
60 | 60 | // We want the field displays the datetime in the good format |
61 | - $options['value'] = $this->getFormattedValueToDisplay($field, $record); |
|
61 | + $options[ 'value' ] = $this->getFormattedValueToDisplay($field, $record); |
|
62 | 62 | |
63 | 63 | return $options; |
64 | 64 | } |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | public function addConditionToSearchQuery(Builder $query, Field $field, $value) : Builder |
124 | 124 | { |
125 | 125 | if (!$this->isEmptyOrNotEmptySearchQuery($query, $field, $value)) { |
126 | - $query->where(function ($query) use($field, $value) { |
|
126 | + $query->where(function($query) use($field, $value) { |
|
127 | 127 | $values = explode(',', $value); // Start Date, End Date |
128 | - $dateStart = \Carbon\Carbon::createFromFormat(config('uccello.format.php.datetime'), trim($values[0])); |
|
129 | - $dateEnd = \Carbon\Carbon::createFromFormat(config('uccello.format.php.datetime'), trim($values[1])); |
|
128 | + $dateStart = \Carbon\Carbon::createFromFormat(config('uccello.format.php.datetime'), trim($values[ 0 ])); |
|
129 | + $dateEnd = \Carbon\Carbon::createFromFormat(config('uccello.format.php.datetime'), trim($values[ 1 ])); |
|
130 | 130 | $query->whereBetween($field->column, [ $dateStart, $dateEnd ])->get(); |
131 | 131 | }); |
132 | 132 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ]; |
46 | 46 | |
47 | 47 | // We want the field displays the date in the good format |
48 | - $options['value'] = $this->getFormattedValueToDisplay($field, $record); |
|
48 | + $options[ 'value' ] = $this->getFormattedValueToDisplay($field, $record); |
|
49 | 49 | |
50 | 50 | return $options; |
51 | 51 | } |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | public function addConditionToSearchQuery(Builder $query, Field $field, $value) : Builder |
111 | 111 | { |
112 | 112 | if (!$this->isEmptyOrNotEmptySearchQuery($query, $field, $value)) { |
113 | - $query->where(function ($query) use($field, $value) { |
|
113 | + $query->where(function($query) use($field, $value) { |
|
114 | 114 | $values = explode(',', $value); // Start Date, End Date |
115 | - $dateStart = \Carbon\Carbon::createFromFormat(config('uccello.format.php.date'), trim($values[0])); |
|
116 | - $dateEnd = \Carbon\Carbon::createFromFormat(config('uccello.format.php.date'), trim($values[1])); |
|
115 | + $dateStart = \Carbon\Carbon::createFromFormat(config('uccello.format.php.date'), trim($values[ 0 ])); |
|
116 | + $dateEnd = \Carbon\Carbon::createFromFormat(config('uccello.format.php.date'), trim($values[ 1 ])); |
|
117 | 117 | $query->whereBetween($field->column, [ $dateStart, $dateEnd ])->get(); |
118 | 118 | }); |
119 | 119 | } |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | public function down() |
45 | 45 | { |
46 | 46 | // Drop table |
47 | - Schema::dropIfExists($this->tablePrefix . 'uccello_groups'); |
|
48 | - Schema::dropIfExists($this->tablePrefix . 'uccello_rl_groups_groups'); |
|
49 | - Schema::dropIfExists($this->tablePrefix . 'uccello_rl_groups_users'); |
|
47 | + Schema::dropIfExists($this->tablePrefix.'uccello_groups'); |
|
48 | + Schema::dropIfExists($this->tablePrefix.'uccello_rl_groups_groups'); |
|
49 | + Schema::dropIfExists($this->tablePrefix.'uccello_rl_groups_users'); |
|
50 | 50 | |
51 | 51 | // Delete module |
52 | 52 | Module::where('name', 'group')->forceDelete(); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | protected function createTables() |
56 | 56 | { |
57 | 57 | // Module Table |
58 | - Schema::create($this->tablePrefix . 'uccello_groups', function (Blueprint $table) { |
|
58 | + Schema::create($this->tablePrefix.'uccello_groups', function(Blueprint $table) { |
|
59 | 59 | $table->increments('id'); |
60 | 60 | $table->string('name')->nullable(); |
61 | 61 | $table->text('description')->nullable(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | }); |
67 | 67 | |
68 | 68 | // Related List Table: Groups-Groups |
69 | - Schema::create($this->tablePrefix . 'uccello_rl_groups_groups', function (Blueprint $table) { |
|
69 | + Schema::create($this->tablePrefix.'uccello_rl_groups_groups', function(Blueprint $table) { |
|
70 | 70 | $table->increments('id'); |
71 | 71 | $table->unsignedInteger('parent_id'); |
72 | 72 | $table->unsignedInteger('children_id'); |
@@ -74,19 +74,19 @@ discard block |
||
74 | 74 | |
75 | 75 | // Foreign keys |
76 | 76 | $table->foreign('parent_id') |
77 | - ->references('id')->on($this->tablePrefix . 'uccello_groups') |
|
77 | + ->references('id')->on($this->tablePrefix.'uccello_groups') |
|
78 | 78 | ->onDelete('cascade'); |
79 | 79 | |
80 | 80 | $table->foreign('children_id') |
81 | - ->references('id')->on($this->tablePrefix . 'uccello_groups') |
|
81 | + ->references('id')->on($this->tablePrefix.'uccello_groups') |
|
82 | 82 | ->onDelete('cascade'); |
83 | 83 | |
84 | 84 | // Unique keys |
85 | - $table->unique(['parent_id', 'children_id']); |
|
85 | + $table->unique([ 'parent_id', 'children_id' ]); |
|
86 | 86 | }); |
87 | 87 | |
88 | 88 | // Related List Table: Groups-Users |
89 | - Schema::create($this->tablePrefix . 'uccello_rl_groups_users', function (Blueprint $table) { |
|
89 | + Schema::create($this->tablePrefix.'uccello_rl_groups_users', function(Blueprint $table) { |
|
90 | 90 | $table->increments('id'); |
91 | 91 | $table->unsignedInteger('group_id'); |
92 | 92 | $table->unsignedInteger('user_id'); |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | |
95 | 95 | // Foreign keys |
96 | 96 | $table->foreign('group_id') |
97 | - ->references('id')->on($this->tablePrefix . 'uccello_groups') |
|
97 | + ->references('id')->on($this->tablePrefix.'uccello_groups') |
|
98 | 98 | ->onDelete('cascade'); |
99 | 99 | |
100 | 100 | $table->foreign('user_id') |
101 | - ->references('id')->on($this->tablePrefix . 'users') |
|
101 | + ->references('id')->on($this->tablePrefix.'users') |
|
102 | 102 | ->onDelete('cascade'); |
103 | 103 | |
104 | 104 | // Unique keys |
105 | - $table->unique(['group_id', 'user_id']); |
|
105 | + $table->unique([ 'group_id', 'user_id' ]); |
|
106 | 106 | }); |
107 | 107 | } |
108 | 108 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $filter->user_id = null; |
169 | 169 | $filter->name = 'filter.all'; |
170 | 170 | $filter->type = 'list'; |
171 | - $filter->columns = [ 'name', 'description']; |
|
171 | + $filter->columns = [ 'name', 'description' ]; |
|
172 | 172 | $filter->conditions = null; |
173 | 173 | $filter->order_by = null; |
174 | 174 | $filter->is_default = true; |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | 'method' => 'getRelatedList', |
201 | 201 | 'data' => [ |
202 | 202 | "relationName" => "childrenGroups", |
203 | - "actions" => ["select", "add"] |
|
203 | + "actions" => [ "select", "add" ] |
|
204 | 204 | ], |
205 | 205 | 'sequence' => 0 |
206 | 206 | ]); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | 'label' => 'relatedlist.users', |
218 | 218 | 'type' => 'n-n', |
219 | 219 | 'method' => 'getRelatedList', |
220 | - 'data' => ["actions" => ["select", "add"]], |
|
220 | + 'data' => [ "actions" => [ "select", "add" ] ], |
|
221 | 221 | 'sequence' => 1 |
222 | 222 | ]); |
223 | 223 | } |
@@ -82,8 +82,7 @@ |
||
82 | 82 | { |
83 | 83 | if (empty($data['conditions'])) { |
84 | 84 | $data['conditions'] = []; |
85 | - } |
|
86 | - else { |
|
85 | + } else { |
|
87 | 86 | $data['conditions'] = (array) $data['conditions']; |
88 | 87 | } |
89 | 88 |
@@ -78,24 +78,24 @@ |
||
78 | 78 | $filter = new static(); |
79 | 79 | |
80 | 80 | // Refactor $data to mach match 'conditions' filter format... |
81 | - if(!empty($data['columns']) && is_array($data['columns']) && is_array(reset($data['columns']))) |
|
81 | + if (!empty($data[ 'columns' ]) && is_array($data[ 'columns' ]) && is_array(reset($data[ 'columns' ]))) |
|
82 | 82 | { |
83 | - if (empty($data['conditions'])) { |
|
84 | - $data['conditions'] = []; |
|
83 | + if (empty($data[ 'conditions' ])) { |
|
84 | + $data[ 'conditions' ] = [ ]; |
|
85 | 85 | } |
86 | 86 | else { |
87 | - $data['conditions'] = (array) $data['conditions']; |
|
87 | + $data[ 'conditions' ] = (array)$data[ 'conditions' ]; |
|
88 | 88 | } |
89 | 89 | |
90 | - foreach ($data['columns'] as $fieldName => $field) { |
|
90 | + foreach ($data[ 'columns' ] as $fieldName => $field) { |
|
91 | 91 | foreach ($field as $key => $value) { |
92 | 92 | if (!empty($value) && $key != 'columnName') { |
93 | - $data['conditions'][$key][$fieldName] = $value; |
|
93 | + $data[ 'conditions' ][ $key ][ $fieldName ] = $value; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - unset($data['columns']); |
|
98 | + unset($data[ 'columns' ]); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | foreach ($data as $key => $value) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $i = 0; |
149 | 149 | foreach ($words as $w) { |
150 | - $initials .= $w[0]; |
|
150 | + $initials .= $w[ 0 ]; |
|
151 | 151 | $i++; |
152 | 152 | |
153 | 153 | if ($i === 3) { // Maximum: 3 letters |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $image = 'vendor/uccello/uccello/images/user-no-image.png'; |
169 | 169 | |
170 | 170 | if ($this->avatarType === 'gravatar') { |
171 | - $image = 'https://www.gravatar.com/avatar/' . md5($this->email) . '?d=mm'; |
|
171 | + $image = 'https://www.gravatar.com/avatar/'.md5($this->email).'?d=mm'; |
|
172 | 172 | |
173 | 173 | } elseif ($this->avatarType === 'image' && !empty($this->avatar->path)) { |
174 | 174 | $image = $this->avatar->path; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function rolesOnDomain($domain) : Collection |
187 | 187 | { |
188 | - return Cache::remember('domain_'.$domain->slug.'_roles', 600, function () use($domain) { |
|
188 | + return Cache::remember('domain_'.$domain->slug.'_roles', 600, function() use($domain) { |
|
189 | 189 | $roles = collect(); |
190 | 190 | |
191 | 191 | if (config('uccello.roles.display_ancestors_roles')) { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | $hasRole = false; |
235 | 235 | |
236 | - $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function () use($domain) { |
|
236 | + $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function() use($domain) { |
|
237 | 237 | return $domain->findDescendants()->get(); |
238 | 238 | }); |
239 | 239 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $keyName = 'user_'.$this->id.'_'.$domain->slug.'_'.$module->name.'_capabilities'; |
261 | 261 | |
262 | - return Cache::remember($keyName, 600, function () use($domain, $module) { |
|
262 | + return Cache::remember($keyName, 600, function() use($domain, $module) { |
|
263 | 263 | $capabilities = collect(); |
264 | 264 | |
265 | 265 | // Get the domain and all its parents |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | $keyName = 'user_'.$this->id.'_'.$domain->slug.'_can_access_to_settings_panel'; |
315 | 315 | |
316 | - return Cache::remember($keyName, 600, function () use($domain) { |
|
316 | + return Cache::remember($keyName, 600, function() use($domain) { |
|
317 | 317 | |
318 | 318 | $hasCapability = false; |
319 | 319 | |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | { |
466 | 466 | // Use cache |
467 | 467 | $allowedGroups = Cache::rememberForever( |
468 | - 'allowed_groups_for_' . ($this->is_admin ? 'admin' : $this->getKey()), |
|
469 | - function () { |
|
468 | + 'allowed_groups_for_'.($this->is_admin ? 'admin' : $this->getKey()), |
|
469 | + function() { |
|
470 | 470 | return $this->getAllowedGroupUuidsProcess(); |
471 | 471 | } |
472 | 472 | ); |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | { |
479 | 479 | // Use cache |
480 | 480 | $allowedGroupsAndUsers = Cache::rememberForever( |
481 | - 'allowed_group_users_for_' . ($addUsers ? 'u_' : '') . ($this->is_admin ? 'admin' : $this->getKey()), |
|
482 | - function () use ($addUsers) { |
|
481 | + 'allowed_group_users_for_'.($addUsers ? 'u_' : '').($this->is_admin ? 'admin' : $this->getKey()), |
|
482 | + function() use ($addUsers) { |
|
483 | 483 | return $this->getAllowedGroupsAndUsersProcess($addUsers); |
484 | 484 | } |
485 | 485 | ); |
@@ -489,16 +489,16 @@ discard block |
||
489 | 489 | |
490 | 490 | protected function getAllowedGroupUuidsProcess() |
491 | 491 | { |
492 | - $allowedUserUuids = collect([$this->uuid]); |
|
492 | + $allowedUserUuids = collect([ $this->uuid ]); |
|
493 | 493 | |
494 | 494 | if ($this->is_admin) { |
495 | 495 | $groups = Group::all(); |
496 | 496 | } else { |
497 | - $groups = []; |
|
498 | - $users = []; |
|
497 | + $groups = [ ]; |
|
498 | + $users = [ ]; |
|
499 | 499 | |
500 | 500 | foreach ($this->groups as $group) { |
501 | - $groups[$group->uuid] = $group; |
|
501 | + $groups[ $group->uuid ] = $group; |
|
502 | 502 | }; |
503 | 503 | |
504 | 504 | $this->addRecursiveChildrenGroups($groups, $users, $groups, false); |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | foreach ($groups as $uuid => $group) { |
510 | - $allowedUserUuids[] = $uuid; |
|
510 | + $allowedUserUuids[ ] = $uuid; |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | return $allowedUserUuids; |
@@ -516,19 +516,19 @@ discard block |
||
516 | 516 | protected function addRecursiveChildrenGroups(&$groups, &$users, $searchGroups, $addUsers = false) |
517 | 517 | { |
518 | 518 | foreach ($searchGroups as $uuid => $searchGroup) { |
519 | - $searchChildrenGroups = []; |
|
519 | + $searchChildrenGroups = [ ]; |
|
520 | 520 | |
521 | 521 | foreach ($searchGroup->childrenGroups as $childrenGroup) { |
522 | - if (empty($groups[$childrenGroup->uuid])) { |
|
523 | - $groups[$childrenGroup->uuid] = $childrenGroup; |
|
524 | - $searchChildrenGroups[$childrenGroup->uuid] = $childrenGroup; |
|
522 | + if (empty($groups[ $childrenGroup->uuid ])) { |
|
523 | + $groups[ $childrenGroup->uuid ] = $childrenGroup; |
|
524 | + $searchChildrenGroups[ $childrenGroup->uuid ] = $childrenGroup; |
|
525 | 525 | } |
526 | 526 | |
527 | - if($addUsers) |
|
527 | + if ($addUsers) |
|
528 | 528 | { |
529 | 529 | foreach ($childrenGroup->users as $user) { |
530 | - if (empty($users[$user->uuid])) { |
|
531 | - $users[$user->uuid] = $user; |
|
530 | + if (empty($users[ $user->uuid ])) { |
|
531 | + $users[ $user->uuid ] = $user; |
|
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
@@ -540,26 +540,26 @@ discard block |
||
540 | 540 | |
541 | 541 | protected function getAllowedGroupsAndUsersProcess($addUsers = true) |
542 | 542 | { |
543 | - $allowedUserUuids = collect([[ |
|
543 | + $allowedUserUuids = collect([ [ |
|
544 | 544 | 'uuid' => $this->uuid, |
545 | 545 | 'recordLabel' => uctrans('me', $this->module) |
546 | - ]]); |
|
546 | + ] ]); |
|
547 | 547 | |
548 | 548 | if ($this->is_admin) { |
549 | 549 | $groups = Group::orderBy('name')->get(); |
550 | 550 | $users = \App\User::orderBy('name')->get(); |
551 | 551 | } else { |
552 | - $groups = []; |
|
553 | - $users = []; |
|
552 | + $groups = [ ]; |
|
553 | + $users = [ ]; |
|
554 | 554 | |
555 | 555 | foreach ($this->groups as $group) { |
556 | - $groups[$group->uuid] = $group; |
|
556 | + $groups[ $group->uuid ] = $group; |
|
557 | 557 | |
558 | - if($addUsers) |
|
558 | + if ($addUsers) |
|
559 | 559 | { |
560 | 560 | foreach ($group->users as $user) { |
561 | - if (empty($users[$user->uuid])) { |
|
562 | - $users[$user->uuid] = $user; |
|
561 | + if (empty($users[ $user->uuid ])) { |
|
562 | + $users[ $user->uuid ] = $user; |
|
563 | 563 | } |
564 | 564 | } |
565 | 565 | } |
@@ -572,15 +572,15 @@ discard block |
||
572 | 572 | } |
573 | 573 | |
574 | 574 | foreach ($groups as $uuid => $group) { |
575 | - $allowedUserUuids[] = [ |
|
575 | + $allowedUserUuids[ ] = [ |
|
576 | 576 | 'uuid' => $group->uuid, |
577 | 577 | 'recordLabel' => $group->recordLabel |
578 | 578 | ]; |
579 | 579 | } |
580 | 580 | |
581 | 581 | foreach ($users as $uuid => $user) { |
582 | - if($user->getKey() != $this->getKey()) { |
|
583 | - $allowedUserUuids[] = [ |
|
582 | + if ($user->getKey() != $this->getKey()) { |
|
583 | + $allowedUserUuids[ ] = [ |
|
584 | 584 | 'uuid' => $user->uuid, |
585 | 585 | 'recordLabel' => $user->recordLabel |
586 | 586 | ]; |
@@ -61,17 +61,17 @@ |
||
61 | 61 | |
62 | 62 | public function parentGroups() |
63 | 63 | { |
64 | - return $this->belongsToMany(static::class, $this->tablePrefix . 'rl_groups_groups', 'children_id', 'parent_id'); |
|
64 | + return $this->belongsToMany(static::class, $this->tablePrefix.'rl_groups_groups', 'children_id', 'parent_id'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function childrenGroups() |
68 | 68 | { |
69 | - return $this->belongsToMany(static::class, $this->tablePrefix . 'rl_groups_groups', 'parent_id', 'children_id'); |
|
69 | + return $this->belongsToMany(static::class, $this->tablePrefix.'rl_groups_groups', 'parent_id', 'children_id'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function users() |
73 | 73 | { |
74 | - return $this->belongsToMany(User::class, $this->tablePrefix . 'rl_groups_users'); |
|
74 | + return $this->belongsToMany(User::class, $this->tablePrefix.'rl_groups_users'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -56,15 +56,15 @@ |
||
56 | 56 | |
57 | 57 | protected static function getModuleFromClass($className) |
58 | 58 | { |
59 | - $modules = Cache::rememberForever('modules_by_model_class', function () { |
|
59 | + $modules = Cache::rememberForever('modules_by_model_class', function() { |
|
60 | 60 | $modulesGroupedByModelClass = collect(); |
61 | - Module::all()->map(function ($item) use ($modulesGroupedByModelClass) { |
|
62 | - $modulesGroupedByModelClass[$item->model_class] = $item; |
|
61 | + Module::all()->map(function($item) use ($modulesGroupedByModelClass) { |
|
62 | + $modulesGroupedByModelClass[ $item->model_class ] = $item; |
|
63 | 63 | return $modulesGroupedByModelClass; |
64 | 64 | }); |
65 | 65 | return $modulesGroupedByModelClass; |
66 | 66 | }); |
67 | - return $modules[(string) $className] ?? null; |
|
67 | + return $modules[ (string)$className ] ?? null; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | public function getUuidAttribute() |