@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | // Related field |
34 | 34 | $relatedField = $relatedList->relatedField; |
35 | - $filter = ['order' => request('order')]; |
|
35 | + $filter = [ 'order' => request('order') ]; |
|
36 | 36 | |
37 | - $query = $query->where(function (Builder $_query) use ($recordId, $relatedList, $relatedField) { |
|
37 | + $query = $query->where(function(Builder $_query) use ($recordId, $relatedList, $relatedField) { |
|
38 | 38 | // Search by id |
39 | 39 | $_query->where($relatedField->column, $recordId); |
40 | 40 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | // Related field |
65 | 65 | $relatedField = $relatedList->relatedField; |
66 | 66 | |
67 | - return $relatedModel::where(function (Builder $_query) use ($recordId, $relatedList, $relatedField) { |
|
67 | + return $relatedModel::where(function(Builder $_query) use ($recordId, $relatedList, $relatedField) { |
|
68 | 68 | // Search by id |
69 | 69 | $_query->where($relatedField->column, $recordId); |
70 | 70 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $relationName = $relatedList->relationName; |
116 | 116 | |
117 | 117 | $record = $modelClass::find($recordId); |
118 | - $filter = ['order' => request('order')]; |
|
118 | + $filter = [ 'order' => request('order') ]; |
|
119 | 119 | |
120 | 120 | $query = $record->$relationName() |
121 | 121 | ->filterBy($filter); |
@@ -51,17 +51,17 @@ discard block |
||
51 | 51 | // Get filters |
52 | 52 | $filters = Filter::where('module_id', $module->id) // Module |
53 | 53 | ->where('type', 'list') // Type (list) |
54 | - ->where(function ($query) use($domain) { // Domain |
|
54 | + ->where(function($query) use($domain) { // Domain |
|
55 | 55 | $query->whereNull('domain_id') |
56 | 56 | ->orWhere('domain_id', $domain->getKey()); |
57 | 57 | }) |
58 | - ->where(function ($query) { // User |
|
58 | + ->where(function($query) { // User |
|
59 | 59 | $query->where('is_public', true) |
60 | - ->orWhere(function ($query) { |
|
60 | + ->orWhere(function($query) { |
|
61 | 61 | $query->where('is_public', false) |
62 | 62 | ->where('user_id', '=', auth()->id()); |
63 | 63 | }) |
64 | - ->orWhere(function ($query) { |
|
64 | + ->orWhere(function($query) { |
|
65 | 65 | $query->where('is_public', false) |
66 | 66 | ->whereNull('user_id'); |
67 | 67 | }); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ->get(); |
71 | 71 | |
72 | 72 | // Order |
73 | - $filterOrder = (array) $selectedFilter->order; |
|
73 | + $filterOrder = (array)$selectedFilter->order; |
|
74 | 74 | |
75 | 75 | // See descendants |
76 | 76 | $seeDescendants = request()->session()->get('descendants'); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | if ($relatedList && $relatedList->method) { |
155 | 155 | // Related list method |
156 | 156 | $method = $relatedList->method; |
157 | - $recordIdsMethod = $method . 'RecordIds'; |
|
157 | + $recordIdsMethod = $method.'RecordIds'; |
|
158 | 158 | |
159 | 159 | // Get related records ids |
160 | 160 | $model = new $modelClass; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | // Add the record id itself to be filtered |
164 | 164 | if ($relatedList->module_id === $relatedList->related_module_id && !empty($recordId) && !$filteredRecordIds->contains($recordId)) { |
165 | - $filteredRecordIds[] = (int)$recordId; |
|
165 | + $filteredRecordIds[ ] = (int)$recordId; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | if ($relatedList->module_id) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $records = $query->paginate($length); |
178 | 178 | } |
179 | 179 | |
180 | - $records->getCollection()->transform(function ($record) use ($domain, $module, $relatedModule) { |
|
180 | + $records->getCollection()->transform(function($record) use ($domain, $module, $relatedModule) { |
|
181 | 181 | foreach ($module->fields as $field) { |
182 | 182 | // If a special template exists, use it. Else use the generic template |
183 | 183 | $uitype = uitype($field->uitype_id); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $results = collect(); |
229 | 229 | if (method_exists($modelClass, 'getSearchResult') && property_exists($modelClass, 'searchableColumns')) { |
230 | 230 | $searchResults = new Search(); |
231 | - $searchResults->registerModel($modelClass, (array) (new $modelClass)->searchableColumns); |
|
231 | + $searchResults->registerModel($modelClass, (array)(new $modelClass)->searchableColumns); |
|
232 | 232 | $results = $searchResults->search($q)->take(config('uccello.max_results.autocomplete', 10)); |
233 | 233 | } |
234 | 234 | |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | $savePageLength = $request->input('save_page_length'); |
250 | 250 | |
251 | 251 | // Optional data |
252 | - $data = []; |
|
252 | + $data = [ ]; |
|
253 | 253 | if ($savePageLength) { |
254 | - $data["length"] = $request->input('page_length'); |
|
254 | + $data[ "length" ] = $request->input('page_length'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $filter = Filter::firstOrNew([ |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | protected function addSearchConditions($filter) |
344 | 344 | { |
345 | 345 | if ($this->request->has('search')) { |
346 | - $conditions = []; |
|
347 | - foreach ((array) $this->request->search as $fieldName => $value) { |
|
348 | - $conditions[$fieldName] = $value; |
|
346 | + $conditions = [ ]; |
|
347 | + foreach ((array)$this->request->search as $fieldName => $value) { |
|
348 | + $conditions[ $fieldName ] = $value; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | if ($conditions) { |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | if ($rules) { |
386 | 386 | foreach ($rules as $column => $rule) { |
387 | - $filter['columns'][$column]['search'] = $rule; |
|
387 | + $filter[ 'columns' ][ $column ][ 'search' ] = $rule; |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -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 | ]; |
@@ -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.'%') |