Skip to main content
Back to packages
647 GitHub stars

Kyslik/column-sortable

View on GitHub

Description

Package for handling column sorting

Use Sortable trait inside your Eloquent model(s). Define $sortable array (see example code below).

NOTE: Scheme::hasColumn() is run only when $sortable is not defined - less DB hits per request.

use Kyslik\ColumnSortable\Sortable;
 
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword, Sortable;
...
 
public $sortable = ['id',
'name',
'email',
'created_at',
'updated_at'];
...
}

You're set to go.

Sortable trait adds Sortable scope to the models so you can use it with paginate.

Blade Extension

There is a blade extension for you to use @sortablelink()

@sortablelink('column', 'Title', ['parameter' => 'smile'], ['rel' => 'nofollow'])

Recent Courses on Laravel Daily

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.