Skip to content

Commit

Permalink
Fix issue #36, now accepting ' and ", formating functions can be passed
Browse files Browse the repository at this point in the history
@sortablelink("id", trans('column-sortable.id'))
@sortablelink("name", "Name")
@sortablelink('email')
@sortablelink('detail.phone_number', trans('column-sortable.phone'))
  • Loading branch information
Kyslik committed Sep 8, 2016
1 parent c0a4a8e commit f446f28
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ There is one blade extension for you to use **@sortablelink**
**Column** (1st) parameter is `order by` and **Title** (2nd) parameter is displayed inside anchor tags.
You can omit **Title** parameter.

>**WARNING**: @sortablelink directive only accepts single quotes
## Config in few words

Sortablelink blade extension distinguishes between "types" (numeric, amount and alpha) and applies different class for each of them. See following snippet:
Expand Down
2 changes: 1 addition & 1 deletion src/ColumnSortable/ColumnSortableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function boot()
Blade::directive('sortablelink', function ($expression) {
//TODO: only accepts single quotes 'Email', would be nice to accept double quotes as well.

This comment has been minimized.

Copy link
@Kyslik

Kyslik Sep 8, 2016

Author Owner

Forgot to remove this TODO 👎

$expression = ($expression[0] === '(') ? substr($expression, 1, -1) : $expression;
return "<?php echo \Kyslik\ColumnSortable\SortableLink::render(\"{$expression}\");?>";
return "<?php echo \Kyslik\ColumnSortable\SortableLink::render(array ({$expression}));?>";
});
}

Expand Down
6 changes: 2 additions & 4 deletions src/ColumnSortable/SortableLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ class SortableLink
{

/**
* @param String $parameters
* @param array $parameters
* @return string
*/
public static function render($parameters)
public static function render(array $parameters)
{
$parameters = str_getcsv($parameters, ',', '\'');

if (count($parameters) === 1) {
$title = self::getOneToOneSortOrNull($parameters[0]);
$title = (is_null($title)) ? $parameters[0] : $title[1];
Expand Down

0 comments on commit f446f28

Please sign in to comment.