We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <!-- elFinder JS (REQUIRED) --> |
18 | 18 | <script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script> |
19 | 19 | |
20 | - <?php if($locale){ ?> |
|
20 | + <?php if ($locale) { ?> |
|
21 | 21 | <!-- elFinder translation (OPTIONAL) --> |
22 | 22 | <script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script> |
23 | 23 | <?php } ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $().ready(function() { |
41 | 41 | var elf = $('#elfinder').elfinder({ |
42 | 42 | // set your elFinder options here |
43 | - <?php if($locale){ ?> |
|
43 | + <?php if ($locale) { ?> |
|
44 | 44 | lang: '<?= $locale ?>', // locale |
45 | 45 | <?php } ?> |
46 | 46 | customData: { |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | $dependencyArray = []; |
16 | 16 | |
17 | 17 | //convert dependency array to simple matrix ( prymary id as key and array with secondaries id ) |
18 | - foreach($dependencies as $primary){ |
|
18 | + foreach ($dependencies as $primary) { |
|
19 | 19 | $dependencyArray[$primary->id] = []; |
20 | - foreach($primary->{$primary_dependency['entity_secondary']} as $secondary){ |
|
20 | + foreach ($primary->{$primary_dependency['entity_secondary']} as $secondary) { |
|
21 | 21 | $dependencyArray[$primary->id][] = $secondary->id; |
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | 25 | //for update form, get initial state of the entity |
26 | - if( isset($id) && $id ){ |
|
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']) |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | $secondary_ids = []; |
40 | 40 | |
41 | 41 | //create secondary dependency from primary relation, used to check what chekbox must be check from second checklist |
42 | - if( old($primary_dependency['name']) ) { |
|
43 | - foreach( old($primary_dependency['name']) as $primary_item ){ |
|
44 | - foreach($dependencyArray[$primary_item] as $second_item ){ |
|
42 | + if (old($primary_dependency['name'])) { |
|
43 | + foreach (old($primary_dependency['name']) as $primary_item) { |
|
44 | + foreach ($dependencyArray[$primary_item] as $second_item) { |
|
45 | 45 | $secondary_ids[$second_item] = $second_item; |
46 | 46 | } |
47 | 47 | } |
48 | - }else{ //create dependecies from relation if not from validate error |
|
49 | - foreach( $primary_array as $primary_item ){ |
|
50 | - foreach($primary_item[$secondary_dependency['entity']] as $second_item ){ |
|
48 | + } else { //create dependecies from relation if not from validate error |
|
49 | + foreach ($primary_array as $primary_item) { |
|
50 | + foreach ($primary_item[$secondary_dependency['entity']] as $second_item) { |
|
51 | 51 | $secondary_ids[$second_item['id']] = $second_item['id']; |
52 | 52 | } |
53 | 53 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $secondary_ids[$second_item] = $second_item; |
46 | 46 | } |
47 | 47 | } |
48 | - }else{ //create dependecies from relation if not from validate error |
|
48 | + } else{ //create dependecies from relation if not from validate error |
|
49 | 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']; |
@@ -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,7 +1,7 @@ |
||
1 | 1 | <!-- select2 --> |
2 | 2 | <div class="form-group"> |
3 | 3 | <label>{{ $field['label'] }}</label> |
4 | - <?php $entity_model = $crud->getModel();?> |
|
4 | + <?php $entity_model = $crud->getModel(); ?> |
|
5 | 5 | |
6 | 6 | <div class="row"> |
7 | 7 | @foreach ($field['model']::all() as $connected_entity_entry) |
@@ -66,7 +66,7 @@ |
||
66 | 66 | |
67 | 67 | private function registerCRUD() |
68 | 68 | { |
69 | - $this->app->bind('CRUD', function ($app) { |
|
69 | + $this->app->bind('CRUD', function($app) { |
|
70 | 70 | return new CRUD($app); |
71 | 71 | }); |
72 | 72 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | * |
70 | 70 | * @param array $columns - the database columns that contain the JSONs |
71 | 71 | * |
72 | - * @return Model |
|
72 | + * @return CrudTrait |
|
73 | 73 | */ |
74 | 74 | public function withFakes($columns = []) |
75 | 75 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | foreach ($columns as $key => $column) { |
51 | 51 | $column_contents = $this->{$column}; |
52 | 52 | |
53 | - if (! is_object($this->{$column})) { |
|
53 | + if (!is_object($this->{$column})) { |
|
54 | 54 | $column_contents = json_decode($this->{$column}); |
55 | 55 | } |
56 | 56 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $model = '\\'.get_class($this); |
75 | 75 | |
76 | - if (! count($columns)) { |
|
76 | + if (!count($columns)) { |
|
77 | 77 | $columns = (property_exists($model, 'fakeColumns')) ? $this->fakeColumns : ['extras']; |
78 | 78 | } |
79 | 79 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $attribute_value = (array) $this->{$attribute_name}; |
164 | 164 | foreach ($files_to_clear as $key => $filename) { |
165 | 165 | \Storage::disk($disk)->delete($filename); |
166 | - $attribute_value = array_where($attribute_value, function ($value, $key) use ($filename) { |
|
166 | + $attribute_value = array_where($attribute_value, function($value, $key) use ($filename) { |
|
167 | 167 | return $value != $filename; |
168 | 168 | }); |
169 | 169 | } |
@@ -2,14 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Backpack\CRUD\app\Http\Controllers; |
4 | 4 | |
5 | -use Backpack\CRUD\app\Http\Requests\CrudRequest as StoreRequest; |
|
6 | -use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
|
7 | 5 | use Backpack\CRUD\Crud; |
6 | +use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
|
8 | 7 | use Illuminate\Foundation\Bus\DispatchesJobs; |
9 | 8 | use Illuminate\Foundation\Validation\ValidatesRequests; |
10 | 9 | // VALIDATION: change the requests to match your own file names if you need form validation |
11 | 10 | use Illuminate\Routing\Controller as BaseController; |
12 | -use Illuminate\Support\Facades\Form as Form; |
|
13 | 11 | |
14 | 12 | class CrudController extends BaseController |
15 | 13 | { |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $this->data['title'] = ucfirst($this->crud->entity_name_plural); |
38 | 38 | |
39 | 39 | // get all entries if AJAX is not enabled |
40 | - if (! $this->data['crud']->ajaxTable()) { |
|
40 | + if (!$this->data['crud']->ajaxTable()) { |
|
41 | 41 | $this->data['entries'] = $this->data['crud']->getEntries(); |
42 | 42 | } |
43 | 43 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | // is somewhat superfluous.. however if we are POSTing, it makes sense to actually have data to post. |
220 | 220 | // Perhaps the route shoud be better named to reflect this (e.g. just /model/{id}/revisions) (??) |
221 | 221 | $revisionId = \Request::input('revision_id', false); |
222 | - if (! $revisionId) { |
|
222 | + if (!$revisionId) { |
|
223 | 223 | abort(500, 'Can\'t restore revision without revision_id'); |
224 | 224 | } else { |
225 | 225 | $this->crud->restoreRevision($id, $revisionId); // do the update |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $this->crud->hasAccessOrFail('reorder'); |
261 | 261 | |
262 | - if (! $this->crud->isReorderEnabled()) { |
|
262 | + if (!$this->crud->isReorderEnabled()) { |
|
263 | 263 | abort(403, 'Reorder is disabled.'); |
264 | 264 | } |
265 | 265 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $dataTable = new DataTable($this->crud->query, $columns); |
331 | 331 | |
332 | 332 | // make the datatable use the column types instead of just echoing the text |
333 | - $dataTable->setFormatRowFunction(function ($entry) { |
|
333 | + $dataTable->setFormatRowFunction(function($entry) { |
|
334 | 334 | // get the actual HTML for each row's cell |
335 | 335 | $row_items = $this->crud->getRowViews($entry, $this->crud); |
336 | 336 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | } else { |
376 | 376 | $existing_entity = $this->crud->model->where([$field_name => $check_value])->first(); |
377 | 377 | |
378 | - if (! $existing_entity) { |
|
378 | + if (!$existing_entity) { |
|
379 | 379 | $response['success'] = true; |
380 | 380 | $response['message'] = null; |
381 | 381 | } else { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | <!-- Include jQuery, jQuery UI, elFinder (REQUIRED) --> |
27 | 27 | |
28 | 28 | <?php |
29 | - $mimeTypes = implode(',', array_map(function ($t) { |
|
29 | + $mimeTypes = implode(',', array_map(function($t) { |
|
30 | 30 | return "'".$t."'"; |
31 | 31 | }, explode(',', $type))); |
32 | 32 | ?> |
@@ -43,7 +43,7 @@ |
||
43 | 43 | |
44 | 44 | foreach ($fields as $k => $field) { |
45 | 45 | // set the value |
46 | - if (! isset($fields[$k]['value'])) { |
|
46 | + if (!isset($fields[$k]['value'])) { |
|
47 | 47 | if (isset($field['subfields'])) { |
48 | 48 | $fields[$k]['value'] = []; |
49 | 49 | foreach ($field['subfields'] as $key => $subfield) { |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | // if the label is missing, we should set it |
30 | - if (! isset($complete_field_array['label'])) { |
|
30 | + if (!isset($complete_field_array['label'])) { |
|
31 | 31 | $complete_field_array['label'] = ucfirst($complete_field_array['name']); |
32 | 32 | } |
33 | 33 | |
34 | 34 | // if the field type is missing, we should set it |
35 | - if (! isset($complete_field_array['type'])) { |
|
35 | + if (!isset($complete_field_array['type'])) { |
|
36 | 36 | $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); |
37 | 37 | } |
38 | 38 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function removeFields($array_of_names, $form = 'both') |
96 | 96 | { |
97 | - if (! empty($array_of_names)) { |
|
97 | + if (!empty($array_of_names)) { |
|
98 | 98 | foreach ($array_of_names as $name) { |
99 | 99 | $this->removeField($name, $form); |
100 | 100 | } |