From 9c36fa276d87b75a1b2c6c051d331afcf9759f3b Mon Sep 17 00:00:00 2001 From: Martin Kiesel Date: Thu, 8 Sep 2016 19:22:29 +0200 Subject: [PATCH] Add .idea to gitignore --- .gitignore | 1 + .../Exceptions/ColumnSortableException.php | 2 +- src/ColumnSortable/Sortable.php | 2 - src/ColumnSortable/SortableLink.php | 42 +++++++++---------- src/config/columnsortable.php | 16 +++---- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 5826402..9c10d38 100755 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.phar composer.lock .DS_Store +.idea diff --git a/src/ColumnSortable/Exceptions/ColumnSortableException.php b/src/ColumnSortable/Exceptions/ColumnSortableException.php index 20c4c76..0467d84 100644 --- a/src/ColumnSortable/Exceptions/ColumnSortableException.php +++ b/src/ColumnSortable/Exceptions/ColumnSortableException.php @@ -13,7 +13,7 @@ public function __construct($message = '', $code = 0, Exception $previous = null $message = 'Invalid sort argument.'; break; case 1: - $message = 'Relation \''. $message . '\' does not exist.'; + $message = 'Relation \'' . $message . '\' does not exist.'; break; case 2: $message = 'Relation \'' . $message . '\' is not instance of HasOne, HasMany or BelongsTo.'; diff --git a/src/ColumnSortable/Sortable.php b/src/ColumnSortable/Sortable.php index 3cfeba0..66c23b2 100755 --- a/src/ColumnSortable/Sortable.php +++ b/src/ColumnSortable/Sortable.php @@ -24,7 +24,6 @@ trait Sortable public function scopeSortable($query, $default = null) { if (Request::has('sort') && Request::has('order')) { - return $this->queryOrderBuilder($query, Request::only(['sort', 'order'])); } elseif (!is_null($default)) { $defaultSortArray = $this->getDefaultSortArray($default); @@ -34,7 +33,6 @@ public function scopeSortable($query, $default = null) return $this->queryOrderBuilder($query, $defaultSortArray); } else { - return $query; } } diff --git a/src/ColumnSortable/SortableLink.php b/src/ColumnSortable/SortableLink.php index ef5877b..d9288eb 100644 --- a/src/ColumnSortable/SortableLink.php +++ b/src/ColumnSortable/SortableLink.php @@ -69,27 +69,6 @@ public static function render(array $parameters) return '' . htmlentities($title) . $trailingTag; } - /** - * @param $sort - * @return array|null - * @throws ColumnSortableException - */ - public static function getOneToOneSortOrNull($sort) - { - $separator = Config::get('columnsortable.uri_relation_column_separator', '.'); - - if (str_contains($sort, $separator)) { - $oneToOneSort = explode($separator, $sort); - if (count($oneToOneSort) !== 2) { - throw new ColumnSortableException(); - } - - return $oneToOneSort; - } - - return null; - } - /** * @param array $parameters * @return array @@ -110,4 +89,25 @@ private static function parseParameters(array $parameters) return [$parameters[0], $title]; } + + /** + * @param $sort + * @return array|null + * @throws ColumnSortableException + */ + public static function getOneToOneSortOrNull($sort) + { + $separator = Config::get('columnsortable.uri_relation_column_separator', '.'); + + if (str_contains($sort, $separator)) { + $oneToOneSort = explode($separator, $sort); + if (count($oneToOneSort) !== 2) { + throw new ColumnSortableException(); + } + + return $oneToOneSort; + } + + return null; + } } diff --git a/src/config/columnsortable.php b/src/config/columnsortable.php index bdbe6a1..1e9ba5f 100755 --- a/src/config/columnsortable.php +++ b/src/config/columnsortable.php @@ -6,15 +6,15 @@ spec columns */ 'columns' => [ - 'alpha' => [ + 'alpha' => [ 'rows' => ['description', 'email', 'name', 'slug'], 'class' => 'fa fa-sort-alpha', ], - 'amount' => [ + 'amount' => [ 'rows' => ['amount', 'price'], 'class' => 'fa fa-sort-amount' ], - 'numeric' => [ + 'numeric' => [ 'rows' => ['created_at', 'updated_at', 'level', 'id', 'phone_number'], 'class' => 'fa fa-sort-numeric' ], @@ -28,7 +28,7 @@ /* icon that shows when generating sortable link while column is not sorted */ - 'sortable_icon' => 'fa fa-sort', + 'sortable_icon' => 'fa fa-sort', /* generated icon is clickable non-clickable (default) @@ -44,17 +44,17 @@ /* suffix class that is appended when ascending order is applied */ - 'asc_suffix' => '-asc', + 'asc_suffix' => '-asc', /* suffix class that is appended when descending order is applied */ - 'desc_suffix' => '-desc', + 'desc_suffix' => '-desc', /* default anchor class, if value is null none is added */ - 'anchor_class' => null, + 'anchor_class' => null, /* relation - column separator ex: detail.phone_number means relation "detail" and column "phone_number" @@ -69,7 +69,7 @@ /* allow request modification, when default sorting is set but is not in URI (first load) */ - 'allow_request_modification' => true, + 'allow_request_modification' => true, /* default order for: $user->sortable('id') usage