@@ -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(false); |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | |
| 64 | 64 | // Create uuid |
| 65 | 65 | Entity::create([ |
| 66 | - 'id' => (string) Str::uuid(), |
|
| 66 | + 'id' => (string)Str::uuid(), |
|
| 67 | 67 | 'module_id' => ucmodule('user')->id, |
| 68 | 68 | 'record_id' => $user->getKey(), |
| 69 | 69 | ]); |
@@ -109,8 +109,8 @@ |
||
| 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; |
@@ -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 | } |
@@ -234,26 +234,26 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | if (is_numeric($nameOrId)) { |
| 236 | 236 | // Use cache |
| 237 | - $modules = Cache::rememberForever('modules_by_id', function () { |
|
| 237 | + $modules = Cache::rememberForever('modules_by_id', function() { |
|
| 238 | 238 | $modulesGroupedById = collect(); |
| 239 | 239 | Module::all()->map(function($item) use($modulesGroupedById) { |
| 240 | - $modulesGroupedById[$item->id] = $item; |
|
| 240 | + $modulesGroupedById[ $item->id ] = $item; |
|
| 241 | 241 | return $modulesGroupedById; |
| 242 | 242 | }); |
| 243 | 243 | return $modulesGroupedById; |
| 244 | 244 | }); |
| 245 | - return $modules[(string) $nameOrId] ?? null; |
|
| 245 | + return $modules[ (string)$nameOrId ] ?? null; |
|
| 246 | 246 | } else { |
| 247 | 247 | // Use cache |
| 248 | - $modules = Cache::rememberForever('modules_by_name', function () { |
|
| 248 | + $modules = Cache::rememberForever('modules_by_name', function() { |
|
| 249 | 249 | $modulesGroupedByName = collect(); |
| 250 | 250 | Module::all()->map(function($item) use($modulesGroupedByName) { |
| 251 | - $modulesGroupedByName[$item->name] = $item; |
|
| 251 | + $modulesGroupedByName[ $item->name ] = $item; |
|
| 252 | 252 | return $modulesGroupedByName; |
| 253 | 253 | }); |
| 254 | 254 | return $modulesGroupedByName; |
| 255 | 255 | }); |
| 256 | - return $modules[(string) $nameOrId] ?? null; |
|
| 256 | + return $modules[ (string)$nameOrId ] ?? null; |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
@@ -271,26 +271,26 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | if (is_numeric($nameOrId)) { |
| 273 | 273 | // Use cache |
| 274 | - $uitypes = Cache::rememberForever('uitypes_by_id', function () { |
|
| 274 | + $uitypes = Cache::rememberForever('uitypes_by_id', function() { |
|
| 275 | 275 | $uitypesGroupedById = collect(); |
| 276 | 276 | Uitype::all()->map(function($item) use($uitypesGroupedById) { |
| 277 | - $uitypesGroupedById[$item->id] = $item; |
|
| 277 | + $uitypesGroupedById[ $item->id ] = $item; |
|
| 278 | 278 | return $uitypesGroupedById; |
| 279 | 279 | }); |
| 280 | 280 | return $uitypesGroupedById; |
| 281 | 281 | }); |
| 282 | - return $uitypes[(string) $nameOrId] ?? null; |
|
| 282 | + return $uitypes[ (string)$nameOrId ] ?? null; |
|
| 283 | 283 | } else { |
| 284 | 284 | // Use cache |
| 285 | - $uitypes = Cache::rememberForever('uitypes_by_name', function () { |
|
| 285 | + $uitypes = Cache::rememberForever('uitypes_by_name', function() { |
|
| 286 | 286 | $uitypesGroupedByName = collect(); |
| 287 | 287 | Uitype::all()->map(function($item) use($uitypesGroupedByName) { |
| 288 | - $uitypesGroupedByName[$item->name] = $item; |
|
| 288 | + $uitypesGroupedByName[ $item->name ] = $item; |
|
| 289 | 289 | return $uitypesGroupedByName; |
| 290 | 290 | }); |
| 291 | 291 | return $uitypesGroupedByName; |
| 292 | 292 | }); |
| 293 | - return $uitypes[(string) $nameOrId] ?? null; |
|
| 293 | + return $uitypes[ (string)$nameOrId ] ?? null; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
@@ -308,26 +308,26 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | if (is_numeric($nameOrId)) { |
| 310 | 310 | // Use cache |
| 311 | - $displaytypes = Cache::rememberForever('displaytypes_by_id', function () { |
|
| 311 | + $displaytypes = Cache::rememberForever('displaytypes_by_id', function() { |
|
| 312 | 312 | $displaytypesGroupedById = collect(); |
| 313 | 313 | Displaytype::all()->map(function($item) use($displaytypesGroupedById) { |
| 314 | - $displaytypesGroupedById[$item->id] = $item; |
|
| 314 | + $displaytypesGroupedById[ $item->id ] = $item; |
|
| 315 | 315 | return $displaytypesGroupedById; |
| 316 | 316 | }); |
| 317 | 317 | return $displaytypesGroupedById; |
| 318 | 318 | }); |
| 319 | - return $displaytypes[(string) $nameOrId] ?? null; |
|
| 319 | + return $displaytypes[ (string)$nameOrId ] ?? null; |
|
| 320 | 320 | } else { |
| 321 | 321 | // Use cache |
| 322 | - $displaytypes = Cache::rememberForever('displaytypes_by_name', function () { |
|
| 322 | + $displaytypes = Cache::rememberForever('displaytypes_by_name', function() { |
|
| 323 | 323 | $displaytypesGroupedByName = collect(); |
| 324 | 324 | Displaytype::all()->map(function($item) use($displaytypesGroupedByName) { |
| 325 | - $displaytypesGroupedByName[$item->name] = $item; |
|
| 325 | + $displaytypesGroupedByName[ $item->name ] = $item; |
|
| 326 | 326 | return $displaytypesGroupedByName; |
| 327 | 327 | }); |
| 328 | 328 | return $displaytypesGroupedByName; |
| 329 | 329 | }); |
| 330 | - return $displaytypes[(string) $nameOrId] ?? null; |
|
| 330 | + return $displaytypes[ (string)$nameOrId ] ?? null; |
|
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | |
@@ -345,26 +345,26 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | if (is_numeric($nameOrId)) { |
| 347 | 347 | // Use cache |
| 348 | - $capabilities = Cache::rememberForever('capabilities_by_id', function () { |
|
| 348 | + $capabilities = Cache::rememberForever('capabilities_by_id', function() { |
|
| 349 | 349 | $capabilitiesGroupedById = collect(); |
| 350 | 350 | Capability::all()->map(function($item) use($capabilitiesGroupedById) { |
| 351 | - $capabilitiesGroupedById[$item->id] = $item; |
|
| 351 | + $capabilitiesGroupedById[ $item->id ] = $item; |
|
| 352 | 352 | return $capabilitiesGroupedById; |
| 353 | 353 | }); |
| 354 | 354 | return $capabilitiesGroupedById; |
| 355 | 355 | }); |
| 356 | - return $capabilities[(string) $nameOrId] ?? null; |
|
| 356 | + return $capabilities[ (string)$nameOrId ] ?? null; |
|
| 357 | 357 | } else { |
| 358 | 358 | // Use cache |
| 359 | - $capabilities = Cache::rememberForever('capabilities_by_name', function () { |
|
| 359 | + $capabilities = Cache::rememberForever('capabilities_by_name', function() { |
|
| 360 | 360 | $capabilitiesGroupedByName = collect(); |
| 361 | 361 | Capability::all()->map(function($item) use($capabilitiesGroupedByName) { |
| 362 | - $capabilitiesGroupedByName[$item->name] = $item; |
|
| 362 | + $capabilitiesGroupedByName[ $item->name ] = $item; |
|
| 363 | 363 | return $capabilitiesGroupedByName; |
| 364 | 364 | }); |
| 365 | 365 | return $capabilitiesGroupedByName; |
| 366 | 366 | }); |
| 367 | - return $capabilities[(string) $nameOrId] ?? null; |
|
| 367 | + return $capabilities[ (string)$nameOrId ] ?? null; |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param string $type |
| 407 | 407 | * @return array |
| 408 | 408 | */ |
| 409 | - public function getDatatableColumns(Module $module, $filterId=null, $type='list'): array |
|
| 409 | + public function getDatatableColumns(Module $module, $filterId = null, $type = 'list'): array |
|
| 410 | 410 | { |
| 411 | 411 | $columns = [ ]; |
| 412 | 412 | |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | * @param string $type |
| 463 | 463 | * @return Filter |
| 464 | 464 | */ |
| 465 | - public function getDefaultFilter(Module $module, $type="list") |
|
| 465 | + public function getDefaultFilter(Module $module, $type = "list") |
|
| 466 | 466 | { |
| 467 | 467 | $filter = Filter::where('module_id', $module->id) |
| 468 | 468 | ->where('type', $type) |