Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied fixes from StyleCI #18

Merged
merged 1 commit into from
May 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function getUpdateFields($id)

foreach ($fields as $k => $field) {
// set the value
if (!isset($fields[$k]['value'])) {
if (! isset($fields[$k]['value'])) {
if (isset($field['subfields'])) {
$fields[$k]['value'] = [];
foreach ($field['subfields'] as $key => $subfield) {
Expand Down Expand Up @@ -418,7 +418,7 @@ public function denyAccess($access)
*/
public function hasAccess($permission)
{
if (!in_array($permission, $this->access)) {
if (! in_array($permission, $this->access)) {
return false;
}

Expand All @@ -434,7 +434,7 @@ public function hasAccess($permission)
*/
public function hasAccessOrFail($permission)
{
if (!in_array($permission, $this->access)) {
if (! in_array($permission, $this->access)) {
abort(403, trans('backpack::crud.unauthorized_access'));
}
}
Expand All @@ -457,7 +457,7 @@ public function hasAccessOrFail($permission)
*/
public function setModel($model_namespace)
{
if (!class_exists($model_namespace)) {
if (! class_exists($model_namespace)) {
throw new \Exception('This model does not exist.', 404);
}

Expand Down Expand Up @@ -501,7 +501,7 @@ public function setRouteName($route, $parameters = [])
{
$complete_route = $route.'.index';

if (!\Route::has($complete_route)) {
if (! \Route::has($complete_route)) {
throw new \Exception('There are no routes for this route name.', 404);
}

Expand Down Expand Up @@ -633,7 +633,7 @@ public function addDefaultTypeToColumn($column)
*/
public function addDefaultLabel($array)
{
if (!array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) {
if (! array_key_exists('label', (array) $array) && array_key_exists('name', (array) $array)) {
$array = array_merge(['label' => ucfirst($this->makeLabel($array['name']))], $array);

return $array;
Expand Down Expand Up @@ -723,12 +723,12 @@ public function addField($field, $form = 'both')
}

// if the label is missing, we should set it
if (!isset($complete_field_array['label'])) {
if (! isset($complete_field_array['label'])) {
$complete_field_array['label'] = ucfirst($complete_field_array['name']);
}

// if the field type is missing, we should set it
if (!isset($complete_field_array['type'])) {
if (! isset($complete_field_array['type'])) {
$complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']);
}

Expand Down Expand Up @@ -790,7 +790,7 @@ public function removeField($name, $form = 'both')
*/
public function removeFields($array_of_names, $form = 'both')
{
if (!empty($array_of_names)) {
if (! empty($array_of_names)) {
foreach ($array_of_names as $name) {
$this->removeField($name, $form);
}
Expand Down Expand Up @@ -935,7 +935,7 @@ public function setFromDb()
$this->create_fields[] = $new_field;
$this->update_fields[] = $new_field;

if (!in_array($field, $this->model->getHidden())) {
if (! in_array($field, $this->model->getHidden())) {
$this->columns[] = [
'name' => $field,
'label' => ucfirst($field),
Expand Down Expand Up @@ -969,7 +969,7 @@ public function getDbColumnTypes()
*/
public function getFieldTypeFromDbColumnType($field)
{
if (!array_key_exists($field, $this->field_types)) {
if (! array_key_exists($field, $this->field_types)) {
return 'text';
}

Expand Down Expand Up @@ -1050,7 +1050,7 @@ public function getDbColumnsNames()
$columns = \Schema::getColumnListing($this->model->getTable());
$fillable = $this->model->getFillable();

if (!empty($fillable)) {
if (! empty($fillable)) {
$columns = array_intersect($columns, $fillable);
}

Expand Down Expand Up @@ -1098,7 +1098,7 @@ public function compactFakeFields($request, $form = 'create')
// remove the fake field
array_pull($request, $fields[$k]['name']);

if (!in_array($fields[$k]['store_in'], $fake_field_columns_to_encode, true)) {
if (! in_array($fields[$k]['store_in'], $fake_field_columns_to_encode, true)) {
array_push($fake_field_columns_to_encode, $fields[$k]['store_in']);
}
} else {
Expand All @@ -1109,7 +1109,7 @@ public function compactFakeFields($request, $form = 'create')
// remove the fake field
array_pull($request, $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');
}
}
Expand Down Expand Up @@ -1152,20 +1152,20 @@ public function getFakeColumnsAsArray($form = 'create')
if (isset($fields[$k]['fake']) && $fields[$k]['fake'] == true) {
// add it to the request in its appropriate variable - the one defined, if defined
if (isset($fields[$k]['store_in'])) {
if (!in_array($fields[$k]['store_in'], $fake_field_columns_to_encode, true)) {
if (! in_array($fields[$k]['store_in'], $fake_field_columns_to_encode, true)) {
array_push($fake_field_columns_to_encode, $fields[$k]['store_in']);
}
} 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');
}
}
}
}

if (!count($fake_field_columns_to_encode)) {
if (! count($fake_field_columns_to_encode)) {
return ['extras'];
}

Expand Down Expand Up @@ -1223,7 +1223,7 @@ public function customButtons()

public function showButtons()
{
return !empty($this->buttons) && !(count($this->buttons) == 1 && array_key_exists('add', $this->buttons));
return ! empty($this->buttons) && ! (count($this->buttons) == 1 && array_key_exists('add', $this->buttons));
}

public function initButtons()
Expand Down Expand Up @@ -1262,7 +1262,7 @@ public function orderFields($order)

public function sync($type, $fields, $attributes)
{
if (!empty($this->{$type})) {
if (! empty($this->{$type})) {
$this->{$type} = array_map(function ($field) use ($fields, $attributes) {
if (in_array($field['name'], (array) $fields)) {
$field = array_merge($field, $attributes);
Expand All @@ -1289,7 +1289,7 @@ public function sort($items)
}
}

return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function ($item) use ($items) {return !in_array($item['name'], $this->sort[$items]); }));
return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function ($item) use ($items) {return ! in_array($item['name'], $this->sort[$items]); }));
}

return $this->{$items};
Expand Down
4 changes: 2 additions & 2 deletions src/CrudTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function addFakes($columns = ['extras'])
foreach ($columns as $key => $column) {
$column_contents = $this->{$column};

if (!is_object($this->{$column})) {
if (! is_object($this->{$column})) {
$column_contents = json_decode($this->{$column});
}

Expand All @@ -75,7 +75,7 @@ public function withFakes($columns = [])
{
$model = '\\'.get_class($this);

if (!count($columns)) {
if (! count($columns)) {
if (property_exists($model, 'fakeColumns')) {
$columns = $this->fakeColumns;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/app/Http/Controllers/CrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function reorder($lang = false)
{
$this->crud->hasAccessOrFail('reorder');

if (!$this->crud->isReorderEnabled()) {
if (! $this->crud->isReorderEnabled()) {
abort(403, 'Reorder is disabled.');
}

Expand Down