Skip to content

Commit

Permalink
composer dependencies change, readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyslik committed Feb 14, 2016
1 parent 02d5f2a commit cd68e32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ In *User* model we define **hasOne** relation to *UserDetail* model (which holds

#### Define `$sortable` array

Define `$sortable` array in both models (else, package uses `Sheme::hasColumn()` which is extra database query).
Define `$sortable` array in both models (else, package uses `Scheme::hasColumn()` which is extra database query).


for *User*
Expand All @@ -199,7 +199,7 @@ for *UserDetail*
public $sortable = ['address', 'phone_number'];
```

>note that `$sortable` array in *UserDetail* is declared as public and not protected because we need to access it inside *User* model.
>note that `$sortable` array in *UserDetail* is declared as **public** and not protected because we need to access it inside *User* model.
#### Blade and relation sorting
In order to tell package to sort using relation:
Expand Down Expand Up @@ -228,12 +228,14 @@ Code **1** means that `$query->getRelation()` method fails, that means when rela

Code **2** means that provided relation through sort argument is not instance of **hasOne**.

In the end you need to catch only one exception, see following example:
Example how to catch:

```
try {
$users = $user->with('detail')->sortable(['detail.phone_number'])->paginate(5);
} catch (ColumnSortableException $e) {
dd($e);
}
```
```

>I strongly recommend to catch **ColumnSortableException** because there is a user input in question (GET parameter) and any user can modify it in such way that package throws ColumnSortableException with code 0.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kyslik/column-sortable",
"description": "Package for handling column sorting in Laravel 5.1 and Laravel 5.2",
"keywords": ["sortable", "sorting", "column", "laravel", "laravel5", "one-to-one"],
"keywords": ["sortable", "sorting", "column", "laravel", "one-to-one"],
"license": "MIT",
"authors": [
{
Expand Down

0 comments on commit cd68e32

Please sign in to comment.