Download the PHP package akaunting/laravel-sortable without Composer

On this page you can find all versions of the php package akaunting/laravel-sortable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-sortable

Sortable behavior package for Laravel

Downloads Tests StyleCI

This package allows you to add sortable behavior to models and views. It ships with a trait where you can set the sortable fields and a blade directive to generate table headers automatically.

Getting Started

1. Install

Run the following command:

2. Publish

Publish configuration

3. Configure

You can change the column sorting settings of your app from config/sortable.php file

Usage

All you have to do is use the Sortable trait inside your model and define the $sortable fields.

If you don't define the $sortable array, the Scheme::hasColumn() function is used which runs an extra database query.

Scope

The trait adds a sortable scope to the model so you can use it just before paginate:

You can set also default sorting field which will be applied when URL is empty.

Blade Directive

There is also a blade directive for you to create sortable links in your views:

The first parameter is the column in database. The second one is displayed inside the anchor tag. The third one is an array(), and it sets the default (GET) query string. The fourth one is also an array() for additional anchor-tag attributes. You can use a custom URL as 'href' attribute in the fourth parameter, which will append the query string.

Only the first parameter is required.

Examples:

Icon Set

You can use any icon set you want. Just change the icons.wrapper from the config file accordingly. By default, it uses Font Awesome.

Blade Component

Same as the directive, there is also a blade component for you to create sortable links in your views:

Sorting Relationships

The package supports HasOne and BelongsTo relational sorting:

And you can use the relation in views:

Note: In case there is a self-referencing model (like comments, categories etc.); parent table will be aliased with parent_ string.

Advanced Relation

You can also extend the relation sorting feature by creating a function with Sortable suffix. There you're free to write your own queries and apply orderBy() manually:

The usage in controller and view remains the same.

Aliasing

You can declare the $sortableAs array in your model and use it to alias (bypass column exists check), and ignore prefixing with table:

In controller

In view

It's very useful when you want to sort results using withCount().

Changelog

Please see Releases for more information what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of laravel-sortable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
laravel/framework Version ^9.0|^10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package akaunting/laravel-sortable contains the following files

Loading the files please wait ....