Skip to content

Commit

Permalink
Add .idea to gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyslik committed Sep 8, 2016
1 parent aa1e425 commit 9c36fa2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
composer.phar
composer.lock
.DS_Store
.idea
2 changes: 1 addition & 1 deletion src/ColumnSortable/Exceptions/ColumnSortableException.php
Expand Up @@ -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.';
Expand Down
2 changes: 0 additions & 2 deletions src/ColumnSortable/Sortable.php
Expand Up @@ -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);
Expand All @@ -34,7 +33,6 @@ public function scopeSortable($query, $default = null)

return $this->queryOrderBuilder($query, $defaultSortArray);
} else {

return $query;
}
}
Expand Down
42 changes: 21 additions & 21 deletions src/ColumnSortable/SortableLink.php
Expand Up @@ -69,27 +69,6 @@ public static function render(array $parameters)
return '<a ' . $anchorClass . ' href="' . url(Request::path() . '?' . $queryString) . '"' . '>' . 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
Expand All @@ -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;
}
}
16 changes: 8 additions & 8 deletions src/config/columnsortable.php
Expand Up @@ -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'
],
Expand All @@ -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)
Expand All @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 9c36fa2

Please sign in to comment.