@@ -59,12 +59,12 @@ |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | - * Get ids of related records for n-1 relations |
|
| 63 | - * |
|
| 64 | - * @param Relatedlist $relatedList |
|
| 65 | - * @param integer $recordId |
|
| 66 | - * @return Collection |
|
| 67 | - */ |
|
| 62 | + * Get ids of related records for n-1 relations |
|
| 63 | + * |
|
| 64 | + * @param Relatedlist $relatedList |
|
| 65 | + * @param integer $recordId |
|
| 66 | + * @return Collection |
|
| 67 | + */ |
|
| 68 | 68 | public function getDependentListRecordIds(Relatedlist $relatedList, int $recordId) : Collection |
| 69 | 69 | { |
| 70 | 70 | // Get record |
@@ -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) { |
@@ -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); |