We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | |
137 | 137 | if( isset($field['pivotFields']) ){ |
138 | 138 | foreach($field['pivotFields'] as $pivotField){ |
139 | - foreach($data[$pivotField] as $pivot_id => $field){ |
|
140 | - $model->{$field['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]); |
|
141 | - } |
|
139 | + foreach($data[$pivotField] as $pivot_id => $field){ |
|
140 | + $model->{$field['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]); |
|
141 | + } |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | |
183 | - /* |
|
183 | + /* |
|
184 | 184 | |-------------------------------------------------------------------------- |
185 | 185 | | READ |
186 | 186 | |-------------------------------------------------------------------------- |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | |
264 | 264 | |
265 | - /* |
|
265 | + /* |
|
266 | 266 | |-------------------------------------------------------------------------- |
267 | 267 | | UPDATE |
268 | 268 | |-------------------------------------------------------------------------- |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | |
328 | 328 | |
329 | 329 | |
330 | - /* |
|
330 | + /* |
|
331 | 331 | |-------------------------------------------------------------------------- |
332 | 332 | | DELETE |
333 | 333 | |-------------------------------------------------------------------------- |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | |
419 | 419 | |
420 | 420 | |
421 | - /* |
|
421 | + /* |
|
422 | 422 | |-------------------------------------------------------------------------- |
423 | 423 | | CRUD ACCESS |
424 | 424 | |-------------------------------------------------------------------------- |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | |
964 | 964 | if (!in_array($field, $this->model->getHidden())) |
965 | 965 | { |
966 | - $this->columns[] = [ |
|
966 | + $this->columns[] = [ |
|
967 | 967 | 'name' => $field, |
968 | 968 | 'label' => ucfirst($field), |
969 | 969 | 'type' => $this->getFieldTypeFromDbColumnType($field) |
@@ -1340,10 +1340,10 @@ discard block |
||
1340 | 1340 | |
1341 | 1341 | public function addCreateField($field) |
1342 | 1342 | { |
1343 | - return $this->add('create_fields', $field); |
|
1343 | + return $this->add('create_fields', $field); |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | - public function setUpdateFields($fields) |
|
1346 | + public function setUpdateFields($fields) |
|
1347 | 1347 | { |
1348 | 1348 | $this->addMultiple('update_fields', $fields); |
1349 | 1349 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $relationFields = []; |
103 | 103 | |
104 | - foreach($fields as $field){ |
|
104 | + foreach ($fields as $field) { |
|
105 | 105 | if (isset($field['model'])) |
106 | 106 | { |
107 | 107 | array_push($relationFields, $field); |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | |
130 | 130 | foreach ($fields_with_relationships as $key => $field) |
131 | 131 | { |
132 | - if (isset($field['pivot']) && $field['pivot'] ) |
|
132 | + if (isset($field['pivot']) && $field['pivot']) |
|
133 | 133 | { |
134 | - $values = isset($data[$field['name']])?$data[$field['name']]:[]; |
|
134 | + $values = isset($data[$field['name']]) ? $data[$field['name']] : []; |
|
135 | 135 | $model->{$field['name']}()->sync($values); |
136 | 136 | |
137 | - if( isset($field['pivotFields']) ){ |
|
138 | - foreach($field['pivotFields'] as $pivotField){ |
|
139 | - foreach($data[$pivotField] as $pivot_id => $field){ |
|
137 | + if (isset($field['pivotFields'])) { |
|
138 | + foreach ($field['pivotFields'] as $pivotField) { |
|
139 | + foreach ($data[$pivotField] as $pivot_id => $field) { |
|
140 | 140 | $model->{$field['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]); |
141 | 141 | } |
142 | 142 | } |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | if (isset($field['subfields'])) |
305 | 305 | { |
306 | 306 | $fields[$k]['value'] = []; |
307 | - foreach($field['subfields'] as $key => $subfield){ |
|
307 | + foreach ($field['subfields'] as $key => $subfield) { |
|
308 | 308 | $fields[$k]['value'][] = $entry->{$subfield['name']}; |
309 | 309 | } |
310 | 310 | |
311 | - }else{ |
|
311 | + } else { |
|
312 | 312 | $fields[$k]['value'] = $entry->{$field['name']}; |
313 | 313 | } |
314 | 314 | } |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | public function allowAccess($access) |
428 | 428 | { |
429 | 429 | // $this->addButtons((array)$access); |
430 | - return $this->access = array_merge(array_diff((array)$access, $this->access), $this->access); |
|
430 | + return $this->access = array_merge(array_diff((array) $access, $this->access), $this->access); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | public function denyAccess($access) |
434 | 434 | { |
435 | 435 | // $this->removeButtons((array)$access); |
436 | - return $this->access = array_diff($this->access, (array)$access); |
|
436 | + return $this->access = array_diff($this->access, (array) $access); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public function addDefaultTypeToColumn($column) |
648 | 648 | { |
649 | - if (array_key_exists('name', (array)$column)) |
|
649 | + if (array_key_exists('name', (array) $column)) |
|
650 | 650 | { |
651 | 651 | $default_type = $this->getFieldTypeFromDbColumnType($column['name']); |
652 | 652 | return array_merge(['type' => $default_type], $column); |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @param [field or column] |
663 | 663 | */ |
664 | 664 | public function addDefaultLabel($array) { |
665 | - if (!array_key_exists('label', (array)$array) && array_key_exists('name', (array)$array)) { |
|
665 | + if (!array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) { |
|
666 | 666 | $array = array_merge(['label' => ucfirst($this->makeLabel($array['name']))], $array); |
667 | 667 | return $array; |
668 | 668 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | * @param [array] $options Field-type-specific information. |
739 | 739 | * @param string $form The form to add the field to (create/update/both) |
740 | 740 | */ |
741 | - public function addField($field, $form='both') |
|
741 | + public function addField($field, $form = 'both') |
|
742 | 742 | { |
743 | 743 | // if the field_defition_array array is a string, it means the programmer was lazy and has only passed the name |
744 | 744 | // set some default values, so the field will still work |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
779 | - public function addFields($fields, $form='both') |
|
779 | + public function addFields($fields, $form = 'both') |
|
780 | 780 | { |
781 | 781 | if (count($fields)) { |
782 | 782 | foreach ($fields as $field) { |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @param string $name Field name (as defined with the addField() procedure) |
791 | 791 | * @param string $form update/create/both |
792 | 792 | */ |
793 | - public function removeField($name, $form='both') |
|
793 | + public function removeField($name, $form = 'both') |
|
794 | 794 | { |
795 | 795 | switch (strtolower($form)) { |
796 | 796 | case 'create': |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * @param array $array_of_names A simple array of the names of the fields to be removed. |
814 | 814 | * @param string $form update/create/both |
815 | 815 | */ |
816 | - public function removeFields($array_of_names, $form='both') |
|
816 | + public function removeFields($array_of_names, $form = 'both') |
|
817 | 817 | { |
818 | 818 | if (!empty($array_of_names)) { |
819 | 819 | foreach ($array_of_names as $name) { |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | array_map(function($field) { |
951 | 951 | // $this->labels[$field] = $this->makeLabel($field); |
952 | 952 | |
953 | - $new_field = [ |
|
953 | + $new_field = [ |
|
954 | 954 | 'name' => $field, |
955 | 955 | 'label' => ucfirst($field), |
956 | 956 | 'value' => '', 'default' => $this->field_types[$field]['default'], |
@@ -1303,7 +1303,7 @@ discard block |
||
1303 | 1303 | |
1304 | 1304 | public function orderColumns($order) |
1305 | 1305 | { |
1306 | - $this->setSort('columns', (array)$order); |
|
1306 | + $this->setSort('columns', (array) $order); |
|
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | |
@@ -1378,7 +1378,7 @@ discard block |
||
1378 | 1378 | |
1379 | 1379 | public function orderFields($order) |
1380 | 1380 | { |
1381 | - $this->setSort('fields', (array)$order); |
|
1381 | + $this->setSort('fields', (array) $order); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | if (!empty($this->{$type})) |
1425 | 1425 | { |
1426 | 1426 | $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
1427 | - if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes); |
|
1427 | + if (in_array($field['name'], (array) $fields)) $field = array_merge($field, $attributes); |
|
1428 | 1428 | |
1429 | 1429 | return $field; |
1430 | 1430 | }, $this->{$type}); |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key]; |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);})); |
|
1457 | + return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]); })); |
|
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | return $this->{$items}; |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | // cred ca ia valorile din tabela de legatura ca sa ti le afiseze in select |
1468 | 1468 | public function getRelationValues($model, $field, $where = [], $order = []) |
1469 | 1469 | { |
1470 | - $order = (array)$order; |
|
1470 | + $order = (array) $order; |
|
1471 | 1471 | $values = $model->select('*'); |
1472 | 1472 | |
1473 | 1473 | if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
@@ -93,8 +93,7 @@ discard block |
||
93 | 93 | if ($form == 'create') |
94 | 94 | { |
95 | 95 | $fields = $this->create_fields; |
96 | - } |
|
97 | - else |
|
96 | + } else |
|
98 | 97 | { |
99 | 98 | $fields = $this->update_fields; |
100 | 99 | } |
@@ -308,7 +307,7 @@ discard block |
||
308 | 307 | $fields[$k]['value'][] = $entry->{$subfield['name']}; |
309 | 308 | } |
310 | 309 | |
311 | - }else{ |
|
310 | + } else{ |
|
312 | 311 | $fields[$k]['value'] = $entry->{$field['name']}; |
313 | 312 | } |
314 | 313 | } |
@@ -487,7 +486,9 @@ discard block |
||
487 | 486 | */ |
488 | 487 | public function setModel($model_namespace) |
489 | 488 | { |
490 | - if (!class_exists($model_namespace)) throw new \Exception('This model does not exist.', 404); |
|
489 | + if (!class_exists($model_namespace)) { |
|
490 | + throw new \Exception('This model does not exist.', 404); |
|
491 | + } |
|
491 | 492 | |
492 | 493 | $this->model = new $model_namespace(); |
493 | 494 | $this->query = $this->model->select('*'); |
@@ -529,7 +530,9 @@ discard block |
||
529 | 530 | { |
530 | 531 | $complete_route = $route.'.index'; |
531 | 532 | |
532 | - if (!\Route::has($complete_route)) throw new \Exception('There are no routes for this route name.', 404); |
|
533 | + if (!\Route::has($complete_route)) { |
|
534 | + throw new \Exception('There are no routes for this route name.', 404); |
|
535 | + } |
|
533 | 536 | |
534 | 537 | $this->route = route($complete_route, $parameters); |
535 | 538 | $this->initButtons(); |
@@ -585,8 +588,7 @@ discard block |
||
585 | 588 | // if label and other details have been defined in the array |
586 | 589 | if (is_array($columns[0])) { |
587 | 590 | $this->addColumn($column); |
588 | - } |
|
589 | - else |
|
591 | + } else |
|
590 | 592 | { |
591 | 593 | $this->addColumn([ |
592 | 594 | 'name' => $column, |
@@ -745,19 +747,20 @@ discard block |
||
745 | 747 | if (is_string($field)) |
746 | 748 | { |
747 | 749 | $complete_field_array['name'] = $field; |
748 | - } |
|
749 | - else |
|
750 | + } else |
|
750 | 751 | { |
751 | 752 | $complete_field_array = $field; |
752 | 753 | } |
753 | 754 | |
754 | 755 | // if the label is missing, we should set it |
755 | - if (!isset($complete_field_array['label'])) |
|
756 | - $complete_field_array['label'] = ucfirst($complete_field_array['name']); |
|
756 | + if (!isset($complete_field_array['label'])) { |
|
757 | + $complete_field_array['label'] = ucfirst($complete_field_array['name']); |
|
758 | + } |
|
757 | 759 | |
758 | 760 | // if the field type is missing, we should set it |
759 | - if (!isset($complete_field_array['type'])) |
|
760 | - $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); |
|
761 | + if (!isset($complete_field_array['type'])) { |
|
762 | + $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); |
|
763 | + } |
|
761 | 764 | |
762 | 765 | // store the field information into the correct variable on the CRUD object |
763 | 766 | switch (strtolower($form)) { |
@@ -840,8 +843,9 @@ discard block |
||
840 | 843 | * @return bool true/false |
841 | 844 | */ |
842 | 845 | public function checkIfFieldIsFirstOfItsType($field, $fields_array) { |
843 | - if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) |
|
844 | - return true; |
|
846 | + if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) { |
|
847 | + return true; |
|
848 | + } |
|
845 | 849 | |
846 | 850 | return false; |
847 | 851 | } |
@@ -998,11 +1002,17 @@ discard block |
||
998 | 1002 | */ |
999 | 1003 | public function getFieldTypeFromDbColumnType($field) |
1000 | 1004 | { |
1001 | - if (!array_key_exists($field, $this->field_types)) return 'text'; |
|
1005 | + if (!array_key_exists($field, $this->field_types)) { |
|
1006 | + return 'text'; |
|
1007 | + } |
|
1002 | 1008 | |
1003 | - if ($field == 'password') return 'password'; |
|
1009 | + if ($field == 'password') { |
|
1010 | + return 'password'; |
|
1011 | + } |
|
1004 | 1012 | |
1005 | - if ($field == 'email') return 'email'; |
|
1013 | + if ($field == 'email') { |
|
1014 | + return 'email'; |
|
1015 | + } |
|
1006 | 1016 | |
1007 | 1017 | switch ($this->field_types[$field]['type']) |
1008 | 1018 | { |
@@ -1075,7 +1085,9 @@ discard block |
||
1075 | 1085 | $columns = \Schema::getColumnListing($this->model->getTable()); |
1076 | 1086 | $fillable = $this->model->getFillable(); |
1077 | 1087 | |
1078 | - if (!empty($fillable)) $columns = array_intersect($columns, $fillable); |
|
1088 | + if (!empty($fillable)) { |
|
1089 | + $columns = array_intersect($columns, $fillable); |
|
1090 | + } |
|
1079 | 1091 | |
1080 | 1092 | // but not updated_at, deleted_at |
1081 | 1093 | return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at'])); |
@@ -1403,8 +1415,11 @@ discard block |
||
1403 | 1415 | |
1404 | 1416 | foreach ($this->{$fields} as $key => $field) |
1405 | 1417 | { |
1406 | - if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); |
|
1407 | - else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; |
|
1418 | + if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) { |
|
1419 | + $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); |
|
1420 | + } else { |
|
1421 | + $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; |
|
1422 | + } |
|
1408 | 1423 | } |
1409 | 1424 | } |
1410 | 1425 | } |
@@ -1424,7 +1439,9 @@ discard block |
||
1424 | 1439 | if (!empty($this->{$type})) |
1425 | 1440 | { |
1426 | 1441 | $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
1427 | - if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes); |
|
1442 | + if (in_array($field['name'], (array)$fields)) { |
|
1443 | + $field = array_merge($field, $attributes); |
|
1444 | + } |
|
1428 | 1445 | |
1429 | 1446 | return $field; |
1430 | 1447 | }, $this->{$type}); |
@@ -1451,7 +1468,9 @@ discard block |
||
1451 | 1468 | |
1452 | 1469 | foreach ($this->sort[$items] as $item) |
1453 | 1470 | { |
1454 | - if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key]; |
|
1471 | + if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) { |
|
1472 | + $elements[] = $this->{$items}[$key]; |
|
1473 | + } |
|
1455 | 1474 | } |
1456 | 1475 | |
1457 | 1476 | return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);})); |
@@ -1470,9 +1489,13 @@ discard block |
||
1470 | 1489 | $order = (array)$order; |
1471 | 1490 | $values = $model->select('*'); |
1472 | 1491 | |
1473 | - if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
|
1492 | + if (!empty($where)) { |
|
1493 | + call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
|
1494 | + } |
|
1474 | 1495 | |
1475 | - if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order); |
|
1496 | + if (!empty($order)) { |
|
1497 | + call_user_func_array([$values, 'orderBy'], $order); |
|
1498 | + } |
|
1476 | 1499 | |
1477 | 1500 | return $values->get()->lists($field, $model->getKeyName())->toArray(); |
1478 | 1501 | } |
@@ -1481,8 +1504,11 @@ discard block |
||
1481 | 1504 | public function syncRelations($entity) |
1482 | 1505 | { |
1483 | 1506 | foreach ($this->relations as $field => $relation) { |
1484 | - if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); |
|
1485 | - else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); |
|
1507 | + if ($relation['pivot']) { |
|
1508 | + $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); |
|
1509 | + } else { |
|
1510 | + $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); |
|
1511 | + } |
|
1486 | 1512 | } |
1487 | 1513 | } |
1488 | 1514 |
@@ -2,34 +2,34 @@ discard block |
||
2 | 2 | <div class="form-group checklist_dependency" data-entity ="{{ $field['field_unique_name'] }}"> |
3 | 3 | <label>{{ $field['label'] }}</label> |
4 | 4 | <?php |
5 | - $entity_model = $crud->getModel(); |
|
5 | + $entity_model = $crud->getModel(); |
|
6 | 6 | |
7 | - //short name for dependency fields |
|
8 | - $primary_dependency = $field['subfields']['primary']; |
|
9 | - $secondary_dependency = $field['subfields']['secondary']; |
|
7 | + //short name for dependency fields |
|
8 | + $primary_dependency = $field['subfields']['primary']; |
|
9 | + $secondary_dependency = $field['subfields']['secondary']; |
|
10 | 10 | |
11 | 11 | |
12 | - //all items with relation |
|
13 | - $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); |
|
12 | + //all items with relation |
|
13 | + $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); |
|
14 | 14 | |
15 | - $dependencyArray = []; |
|
15 | + $dependencyArray = []; |
|
16 | 16 | |
17 | - //convert dependency array to simple matrix ( prymary id as key and array with secondaries id ) |
|
18 | - foreach($dependencies as $primary){ |
|
19 | - $dependencyArray[$primary->id] = []; |
|
17 | + //convert dependency array to simple matrix ( prymary id as key and array with secondaries id ) |
|
18 | + foreach($dependencies as $primary){ |
|
19 | + $dependencyArray[$primary->id] = []; |
|
20 | 20 | foreach($primary->{$primary_dependency['entity_secondary']} as $secondary){ |
21 | 21 | $dependencyArray[$primary->id][] = $secondary->id; |
22 | 22 | } |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | - //for update form, get initial state of the entity |
|
26 | - if( isset($id) && $id ){ |
|
25 | + //for update form, get initial state of the entity |
|
26 | + if( isset($id) && $id ){ |
|
27 | 27 | |
28 | 28 | //get entity with relations for primary dependency |
29 | 29 | $entity_dependencies = $entity_model->with($primary_dependency['entity']) |
30 | - ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) |
|
31 | - ->where('id', $id) |
|
32 | - ->first(); |
|
30 | + ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) |
|
31 | + ->where('id', $id) |
|
32 | + ->first(); |
|
33 | 33 | |
34 | 34 | $secondaries_from_primary = []; |
35 | 35 | |
@@ -40,23 +40,23 @@ discard block |
||
40 | 40 | |
41 | 41 | //create secondary dependency from primary relation, used to check what chekbox must be check from second checklist |
42 | 42 | if( old($primary_dependency['name']) ) { |
43 | - foreach( old($primary_dependency['name']) as $primary_item ){ |
|
43 | + foreach( old($primary_dependency['name']) as $primary_item ){ |
|
44 | 44 | foreach($dependencyArray[$primary_item] as $second_item ){ |
45 | 45 | $secondary_ids[$second_item] = $second_item; |
46 | 46 | } |
47 | - } |
|
47 | + } |
|
48 | 48 | }else{ //create dependecies from relation if not from validate error |
49 | - foreach( $primary_array as $primary_item ){ |
|
49 | + foreach( $primary_array as $primary_item ){ |
|
50 | 50 | foreach($primary_item[$secondary_dependency['entity']] as $second_item ){ |
51 | 51 | $secondary_ids[$second_item['id']] = $second_item['id']; |
52 | 52 | } |
53 | - } |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | |
56 | - } |
|
56 | + } |
|
57 | 57 | |
58 | - //json encode of dependency matrix |
|
59 | - $dependencyJson = json_encode($dependencyArray); |
|
58 | + //json encode of dependency matrix |
|
59 | + $dependencyJson = json_encode($dependencyArray); |
|
60 | 60 | ?> |
61 | 61 | <script> |
62 | 62 | var {{ $field['field_unique_name'] }} = {!! $dependencyJson !!}; |