Skip to content

Commit

Permalink
Fix sortablelink directive not accepting second parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyslik committed Sep 7, 2016
1 parent 8d10307 commit 9b745e9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ Sortable trait adds Sortable scope to the models so you can use it with paginate

## Blade Extension

There is one blade extension for you to use
There is one blade extension for you to use **@sortablelink**

```
@sortablelink('column', 'Title')
@sortablelink('name')
```

**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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
],
"require": {
"php": ">=5.6.4",
"Illuminate/Support": "^5.0",
"Illuminate/Database": "^5.0"
"Illuminate/Support": "5.1.* || 5.2.* || 5.3.*",
"Illuminate/Database": "5.1.* || 5.2.* || 5.3.*"
},
"require-dev": {
"phpunit/phpunit": "~5.0",
Expand Down
3 changes: 2 additions & 1 deletion src/ColumnSortable/ColumnSortableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public function boot()
], 'config');

Blade::directive('sortablelink', function ($expression) {
//TODO: only accepts single quotes 'Email', would be nice to accept double quotes as well.
$expression = ($expression[0] === '(') ? substr($expression, 1, -1) : $expression;
return "<?php echo \Kyslik\ColumnSortable\SortableLink::render({$expression});?>";
return "<?php echo \Kyslik\ColumnSortable\SortableLink::render(\"{$expression}\");?>";
});
}

Expand Down
1 change: 0 additions & 1 deletion src/ColumnSortable/Sortable.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function scopeSortable($query, $default = null)
private function queryOrderBuilder($query, array $sortArray)
{
$model = $this;
//dd($model);
$direction = array_get($sortArray, 'order', 'asc');

if (!in_array($direction, ['asc', 'desc'])) {
Expand Down

0 comments on commit 9b745e9

Please sign in to comment.