From 6049c574a35f1bef18c72165c3568b4d098f9e10 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 16 Mar 2016 22:39:47 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- src/CrudServiceProvider.php | 8 +-- src/CrudTrait.php | 13 +++-- src/app/Http/Controllers/CrudController.php | 50 ++++++++----------- src/resources/views-elfinder/filepicker.php | 10 ++-- .../views/fields/page_or_link.blade.php | 6 +-- src/resources/views/form_content.blade.php | 4 +- src/resources/views/list.blade.php | 16 +++--- 7 files changed, 50 insertions(+), 57 deletions(-) diff --git a/src/CrudServiceProvider.php b/src/CrudServiceProvider.php index 1948cc96bd..27daf44675 100644 --- a/src/CrudServiceProvider.php +++ b/src/CrudServiceProvider.php @@ -32,11 +32,11 @@ public function boot() // PUBLISH FILES // publish lang files - $this->publishes([ __DIR__.'/resources/lang' => resource_path('lang/vendor/backpack'), ], 'lang'); + $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack'), ], 'lang'); // publish views - $this->publishes([ __DIR__.'/resources/views' => resource_path('views/vendor/backpack/crud'), ], 'views'); + $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/crud'), ], 'views'); // publish public Backpack CRUD assets - $this->publishes([ __DIR__.'/public' => public_path('vendor/backpack'), ], 'public'); + $this->publishes([__DIR__.'/public' => public_path('vendor/backpack'), ], 'public'); // publish custom files for elFinder $this->publishes([ __DIR__.'/config/elfinder.php' => config_path('elfinder.php'), @@ -68,7 +68,7 @@ public function register() private function registerCRUD() { - $this->app->bind('CRUD',function($app){ + $this->app->bind('CRUD', function($app) { return new CRUD($app); }); } diff --git a/src/CrudTrait.php b/src/CrudTrait.php index 04df7f3e84..908593463f 100644 --- a/src/CrudTrait.php +++ b/src/CrudTrait.php @@ -12,7 +12,7 @@ trait CrudTrait { |-------------------------------------------------------------------------- */ - public static function getPossibleEnumValues($field_name){ + public static function getPossibleEnumValues($field_name){ $instance = new static; // create an instance of the model to be able to get the table name $type = DB::select( DB::raw('SHOW COLUMNS FROM '.$instance->getTable().' WHERE Field = "'.$field_name.'"') )[0]->Type; preg_match('/^enum\((.*)\)$/', $type, $matches); @@ -27,9 +27,9 @@ public static function getPossibleEnumValues($field_name){ public static function isColumnNullable($column_name) { $instance = new static; // create an instance of the model to be able to get the table name - $answer = DB::select( DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$instance->getTable()."' AND COLUMN_NAME='".$column_name."' AND table_schema='".env('DB_DATABASE')."'") )[0]; + $answer = DB::select(DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$instance->getTable()."' AND COLUMN_NAME='".$column_name."' AND table_schema='".env('DB_DATABASE')."'"))[0]; - return ($answer->IS_NULLABLE == 'YES'?true:false); + return ($answer->IS_NULLABLE == 'YES' ? true : false); } @@ -67,7 +67,7 @@ public function addFakes($columns = ['extras']) { * Return the entity with fake fields as attributes. * * @param array $columns - the database columns that contain the JSONs - * @return obj + * @return CrudTrait */ public function withFakes($columns = []) { @@ -76,8 +76,7 @@ public function withFakes($columns = []) if (!count($columns)) { if (property_exists($model, 'fakeColumns')) { $columns = $this->fakeColumns; - } - else + } else { $columns = ['extras']; } @@ -128,7 +127,7 @@ public function allTranslations() public function translation($translation_lang = false) { - if ($translation_lang==false) { + if ($translation_lang == false) { $translation_lang = Lang::locale(); } diff --git a/src/app/Http/Controllers/CrudController.php b/src/app/Http/Controllers/CrudController.php index 93541e3537..a0ac5df6cb 100644 --- a/src/app/Http/Controllers/CrudController.php +++ b/src/app/Http/Controllers/CrudController.php @@ -53,8 +53,7 @@ public function index() if (property_exists($model, 'translatable')) { $this->data['entries'] = $model::where('translation_lang', \Lang::locale())->get(); - } - else + } else { $this->data['entries'] = $model::all(); } @@ -106,7 +105,7 @@ public function create() * Store a newly created resource in the database. * * @param StoreRequest $request - type injection used for validation using Requests - * @return Response + * @return \Illuminate\Http\RedirectResponse */ public function storeCrud(StoreRequest $request = null) { @@ -124,7 +123,7 @@ public function storeCrud(StoreRequest $request = null) // if it's a relationship with a pivot table, also sync that $this->prepareFields(); foreach ($this->crud['fields'] as $k => $field) { - if (isset($field['pivot']) && $field['pivot']==true && \Request::has($field['name'])) + if (isset($field['pivot']) && $field['pivot'] == true && \Request::has($field['name'])) { $model::find($item->id)->$field['name']()->attach(\Request::input($field['name'])); } @@ -182,7 +181,7 @@ public function edit($id) * Update the specified resource in the database. * * @param UpdateRequest $request - type injection used for validation using Requests - * @return Response + * @return \Illuminate\Http\RedirectResponse */ public function updateCrud(UpdateRequest $request = null) { @@ -198,7 +197,7 @@ public function updateCrud(UpdateRequest $request = null) // if it's a relationship with a pivot table, also sync that foreach ($this->crud['fields'] as $k => $field) { - if (isset($field['pivot']) && $field['pivot']==true && \Request::has($field['name'])) + if (isset($field['pivot']) && $field['pivot'] == true && \Request::has($field['name'])) { $model::find(\Request::input('id'))->$field['name']()->sync(\Request::input($field['name'])); } @@ -235,7 +234,7 @@ public function show($id) * Remove the specified resource from storage. * * @param int $id - * @return Response + * @return string */ public function destroy($id) { @@ -279,8 +278,7 @@ public function reorder($lang = false) $this->data['entries'] = $model::where('translation_lang', $lang)->get(); $this->data['languages'] = \Backpack\LangFileManager\app\Models\Language::all(); $this->data['active_language'] = $lang; - } - else + } else { $this->data['entries'] = $model::all(); } @@ -323,8 +321,7 @@ public function saveReorder() $count++; } } - } - else + } else { return false; } @@ -358,7 +355,7 @@ public function showDetailsRow($id) $this->data['languages'] = \Backpack\LangFileManager\app\Models\Language::all(); $this->data['languages_already_translated_in'] = $this->data['entry']->translationLanguages(); $this->data['languages_to_translate_in'] = $this->data['languages']->diff($this->data['languages_already_translated_in']); - $this->data['languages_to_translate_in'] = $this->data['languages_to_translate_in']->reject(function ($item) { + $this->data['languages_to_translate_in'] = $this->data['languages_to_translate_in']->reject(function($item) { return $item->abbr == \Lang::locale(); }); } @@ -381,8 +378,7 @@ public function translateItem($id, $lang) if ($existing_translation) { $new_entry = $existing_translation; - } - else + } else { // get the info for that entry $new_entry_attributes = $this->data['entry']->getAttributes(); @@ -421,22 +417,21 @@ protected function compactFakeFields($request) { // go through each defined field foreach ($this->crud['fields'] as $k => $field) { // if it's a fake field - if (isset($this->crud['fields'][$k]['fake']) && $this->crud['fields'][$k]['fake']==true) { + if (isset($this->crud['fields'][$k]['fake']) && $this->crud['fields'][$k]['fake'] == true) { // add it to the request in its appropriate variable - the one defined, if defined if (isset($this->crud['fields'][$k]['store_in'])) { $request[$this->crud['fields'][$k]['store_in']][$this->crud['fields'][$k]['name']] = $request[$this->crud['fields'][$k]['name']]; $remove_fake_field = array_pull($request, $this->crud['fields'][$k]['name']); - if(!in_array($this->crud['fields'][$k]['store_in'], $fake_field_columns_to_encode, true)){ + if (!in_array($this->crud['fields'][$k]['store_in'], $fake_field_columns_to_encode, true)) { array_push($fake_field_columns_to_encode, $this->crud['fields'][$k]['store_in']); } - } - else //otherwise in the one defined in the $crud variable + } else //otherwise in the one defined in the $crud variable { $request['extras'][$this->crud['fields'][$k]['name']] = $request[$this->crud['fields'][$k]['name']]; $remove_fake_field = array_pull($request, $this->crud['fields'][$k]['name']); - if(!in_array('extras', $fake_field_columns_to_encode, true)){ + if (!in_array('extras', $fake_field_columns_to_encode, true)) { array_push($fake_field_columns_to_encode, 'extras'); } } @@ -469,16 +464,15 @@ protected function getFakeColumnsAsArray() { foreach ($this->crud['fields'] as $k => $field) { // if it's a fake field - if (isset($this->crud['fields'][$k]['fake']) && $this->crud['fields'][$k]['fake']==true) { + if (isset($this->crud['fields'][$k]['fake']) && $this->crud['fields'][$k]['fake'] == true) { // add it to the request in its appropriate variable - the one defined, if defined if (isset($this->crud['fields'][$k]['store_in'])) { - if(!in_array($this->crud['fields'][$k]['store_in'], $fake_field_columns_to_encode, true)){ + if (!in_array($this->crud['fields'][$k]['store_in'], $fake_field_columns_to_encode, true)) { array_push($fake_field_columns_to_encode, $this->crud['fields'][$k]['store_in']); } - } - else //otherwise in the one defined in the $crud variable + } else //otherwise in the one defined in the $crud variable { - if(!in_array('extras', $fake_field_columns_to_encode, true)){ + if (!in_array('extras', $fake_field_columns_to_encode, true)) { array_push($fake_field_columns_to_encode, 'extras'); } } @@ -536,8 +530,7 @@ protected function prepareFields($entry = false) if (isset($this->crud['create_fields'])) { $this->crud['fields'] = $this->crud['create_fields']; - } - elseif (isset($this->crud['update_fields'])) + } elseif (isset($this->crud['update_fields'])) { $this->crud['fields'] = $this->crud['update_fields']; } @@ -569,8 +562,9 @@ protected function prepareFields($entry = false) // if no field type is defined, assume the "text" field type foreach ($this->crud['fields'] as $k => $field) { - if (!isset($this->crud['fields'][$k]['type'])) - $this->crud['fields'][$k]['type'] = 'text'; + if (!isset($this->crud['fields'][$k]['type'])) { + $this->crud['fields'][$k]['type'] = 'text'; + } } // if an entry was passed, we're preparing for the update form, not create diff --git a/src/resources/views-elfinder/filepicker.php b/src/resources/views-elfinder/filepicker.php index bc37e7fb89..9dd2ba73f3 100644 --- a/src/resources/views-elfinder/filepicker.php +++ b/src/resources/views-elfinder/filepicker.php @@ -10,28 +10,28 @@ - + - + - +