We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -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 !!}; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | {{-- checkbox with loose false/null/0 checking --}} |
2 | 2 | <?php |
3 | - $icon = "fa-check-square-o"; |
|
4 | - if (strip_tags($entry->{$column['name']}) == false) |
|
5 | - { |
|
6 | - $icon = "fa-square-o"; |
|
7 | - } |
|
3 | + $icon = "fa-check-square-o"; |
|
4 | + if (strip_tags($entry->{$column['name']}) == false) |
|
5 | + { |
|
6 | + $icon = "fa-square-o"; |
|
7 | + } |
|
8 | 8 | ?> |
9 | 9 | |
10 | 10 | <td> |
@@ -1,6 +1,6 @@ |
||
1 | 1 | {{-- custom return value via attribute --}} |
2 | 2 | <td> |
3 | 3 | <?php |
4 | - echo $entry->{$column['function_name']}()->{$column['attribute']}; |
|
4 | + echo $entry->{$column['function_name']}()->{$column['attribute']}; |
|
5 | 5 | ?> |
6 | 6 | </td> |
7 | 7 | \ No newline at end of file |
@@ -1,8 +1,8 @@ |
||
1 | 1 | {{-- single relationships (1-1, 1-n) --}} |
2 | 2 | <td> |
3 | 3 | <?php |
4 | - if ($entry->{$column['entity']}()->getResults()) { |
|
5 | - echo $entry->{$column['entity']}()->getResults()->{$column['attribute']}; |
|
6 | - } |
|
7 | - ?> |
|
4 | + if ($entry->{$column['entity']}()->getResults()) { |
|
5 | + echo $entry->{$column['entity']}()->getResults()->{$column['attribute']}; |
|
6 | + } |
|
7 | + ?> |
|
8 | 8 | </td> |
9 | 9 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | {{-- custom return value --}} |
2 | 2 | <td> |
3 | 3 | <?php |
4 | - echo $entry->{$column['function_name']}(); |
|
4 | + echo $entry->{$column['function_name']}(); |
|
5 | 5 | ?> |
6 | 6 | </td> |
7 | 7 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | {{-- enumerate the values in an array --}} |
2 | 2 | <td> |
3 | 3 | <?php |
4 | - $value = $entry->{$column['name']}; |
|
4 | + $value = $entry->{$column['name']}; |
|
5 | 5 | |
6 | - // the value should be an array wether or not attribute casting is used |
|
7 | - if (!is_array($value)) { |
|
8 | - $value = json_decode($value, true); |
|
9 | - } |
|
6 | + // the value should be an array wether or not attribute casting is used |
|
7 | + if (!is_array($value)) { |
|
8 | + $value = json_decode($value, true); |
|
9 | + } |
|
10 | 10 | |
11 | 11 | if ($value && count($value)) { |
12 | 12 | echo implode(', ', $value); |
@@ -20,42 +20,42 @@ discard block |
||
20 | 20 | |
21 | 21 | @section('content') |
22 | 22 | <?php |
23 | - function tree_element($entry, $key, $all_entries, $crud) |
|
24 | - { |
|
23 | + function tree_element($entry, $key, $all_entries, $crud) |
|
24 | + { |
|
25 | 25 | if (!isset($entry->tree_element_shown)) { |
26 | - // mark the element as shown |
|
27 | - $all_entries[$key]->tree_element_shown = true; |
|
28 | - $entry->tree_element_shown = true; |
|
26 | + // mark the element as shown |
|
27 | + $all_entries[$key]->tree_element_shown = true; |
|
28 | + $entry->tree_element_shown = true; |
|
29 | 29 | |
30 | - // show the tree element |
|
31 | - echo '<li id="list_'.$entry->getKey().'">'; |
|
32 | - echo '<div><span class="disclose"><span></span></span>'.$entry->{$crud->reorder_label}.'</div>'; |
|
30 | + // show the tree element |
|
31 | + echo '<li id="list_'.$entry->getKey().'">'; |
|
32 | + echo '<div><span class="disclose"><span></span></span>'.$entry->{$crud->reorder_label}.'</div>'; |
|
33 | 33 | |
34 | - // see if this element has any children |
|
35 | - $children = []; |
|
36 | - foreach ($all_entries as $key => $subentry) { |
|
34 | + // see if this element has any children |
|
35 | + $children = []; |
|
36 | + foreach ($all_entries as $key => $subentry) { |
|
37 | 37 | if ($subentry->parent_id == $entry->getKey()) { |
38 | - $children[] = $subentry; |
|
38 | + $children[] = $subentry; |
|
39 | + } |
|
39 | 40 | } |
40 | - } |
|
41 | 41 | |
42 | - $children = collect($children)->sortBy('lft'); |
|
42 | + $children = collect($children)->sortBy('lft'); |
|
43 | 43 | |
44 | - // if it does have children, show them |
|
45 | - if (count($children)) { |
|
44 | + // if it does have children, show them |
|
45 | + if (count($children)) { |
|
46 | 46 | echo '<ol>'; |
47 | 47 | foreach ($children as $key => $child) { |
48 | - $children[$key] = tree_element($child, $child->getKey(), $all_entries, $crud); |
|
48 | + $children[$key] = tree_element($child, $child->getKey(), $all_entries, $crud); |
|
49 | 49 | } |
50 | 50 | echo '</ol>'; |
51 | - } |
|
52 | - echo '</li>'; |
|
51 | + } |
|
52 | + echo '</li>'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return $entry; |
56 | - } |
|
56 | + } |
|
57 | 57 | |
58 | - ?> |
|
58 | + ?> |
|
59 | 59 | <div class="row"> |
60 | 60 | <div class="col-md-8 col-md-offset-2"> |
61 | 61 | @if ($crud->hasAccess('list')) |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | |
74 | 74 | <ol class="sortable"> |
75 | 75 | <?php |
76 | - $all_entries = collect($entries->all())->sortBy('lft')->keyBy($crud->getModel()->getKeyName()); |
|
77 | - $root_entries = $all_entries->filter(function($item) { |
|
76 | + $all_entries = collect($entries->all())->sortBy('lft')->keyBy($crud->getModel()->getKeyName()); |
|
77 | + $root_entries = $all_entries->filter(function($item) { |
|
78 | 78 | return $item->parent_id == 0; |
79 | - }); |
|
80 | - ?> |
|
79 | + }); |
|
80 | + ?> |
|
81 | 81 | @foreach ($root_entries as $key => $entry) |
82 | 82 | <?php |
83 | 83 | $root_entries[$key] = tree_element($entry, $key, $all_entries, $crud); |
84 | - ?> |
|
84 | + ?> |
|
85 | 85 | @endforeach |
86 | 86 | </ol> |
87 | 87 |
@@ -356,38 +356,38 @@ |
||
356 | 356 | return $dataTable->make(); |
357 | 357 | } |
358 | 358 | |
359 | - /** |
|
360 | - * Checks if the given string is unique, and return existing entity. |
|
361 | - * @return JSON containing success, message and data. |
|
362 | - */ |
|
363 | - public function unicity() |
|
364 | - { |
|
365 | - $response = ['success' => false, 'message' => trans('backpack::crud.unique_error'), 'meta' => ['link' => null, 'snippet' => null, 'entity_key' => null]]; |
|
366 | - |
|
367 | - $field_name = \Request::input('field_name', null); |
|
368 | - $check_value = \Request::input('check_value', null); |
|
369 | - $display_name = \Request::input('display_name', null); |
|
370 | - |
|
371 | - if (empty($field_name)) { |
|
372 | - $response['message'] = trans('backpack::crud.unique_field_name_missing'); |
|
373 | - } elseif (empty($check_value) && $check_value !== '0') { |
|
374 | - $response['message'] = trans('backpack::crud.unique_check_value_missing'); |
|
375 | - } else { |
|
376 | - $existing_entity = $this->crud->model->where([$field_name => $check_value])->first(); |
|
377 | - |
|
378 | - if (! $existing_entity) { |
|
379 | - $response['success'] = true; |
|
380 | - $response['message'] = null; |
|
381 | - } else { |
|
382 | - $response['message'] = $this->crud->entity_name.' '.trans('backpack::crud.unique_exists'); |
|
383 | - $response['meta'] = [ |
|
359 | + /** |
|
360 | + * Checks if the given string is unique, and return existing entity. |
|
361 | + * @return JSON containing success, message and data. |
|
362 | + */ |
|
363 | + public function unicity() |
|
364 | + { |
|
365 | + $response = ['success' => false, 'message' => trans('backpack::crud.unique_error'), 'meta' => ['link' => null, 'snippet' => null, 'entity_key' => null]]; |
|
366 | + |
|
367 | + $field_name = \Request::input('field_name', null); |
|
368 | + $check_value = \Request::input('check_value', null); |
|
369 | + $display_name = \Request::input('display_name', null); |
|
370 | + |
|
371 | + if (empty($field_name)) { |
|
372 | + $response['message'] = trans('backpack::crud.unique_field_name_missing'); |
|
373 | + } elseif (empty($check_value) && $check_value !== '0') { |
|
374 | + $response['message'] = trans('backpack::crud.unique_check_value_missing'); |
|
375 | + } else { |
|
376 | + $existing_entity = $this->crud->model->where([$field_name => $check_value])->first(); |
|
377 | + |
|
378 | + if (! $existing_entity) { |
|
379 | + $response['success'] = true; |
|
380 | + $response['message'] = null; |
|
381 | + } else { |
|
382 | + $response['message'] = $this->crud->entity_name.' '.trans('backpack::crud.unique_exists'); |
|
383 | + $response['meta'] = [ |
|
384 | 384 | 'link' => url($this->crud->route.'/'.$existing_entity->getKey().'/edit'), |
385 | 385 | 'snippet' => $display_name ? $existing_entity->{$display_name} : $this->crud->entity_name, |
386 | 386 | 'entity_key' => $existing_entity->getKey(), |
387 | 387 | ]; |
388 | - } |
|
389 | - } |
|
388 | + } |
|
389 | + } |
|
390 | 390 | |
391 | - return $response; |
|
392 | - } |
|
391 | + return $response; |
|
392 | + } |
|
393 | 393 | } |