Download the PHP package jedrzej/sortable without Composer

On this page you can find all versions of the php package jedrzej/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 sortable

Sortable trait for Laravel's Eloquent models

This package adds sorting functionality to Eloquent models in Laravel 4/5/6.

You could also find those packages useful:

Composer install

Add the following line to composer.json file in your project:

"jedrzej/sortable": "0.0.12"

or run the following in the commandline in your project's root folder:

composer require "jedrzej/sortable" "0.0.12"

Setting up sortable models

In order to make an Eloquent model sortable, add the trait to the model and define a list of fields that the model can be sorted by. You can either define a $sortable property or implement a getSortableAttributes method if you want to execute some logic to define list of sortable fields.

In order to make all fields sortable put an asterisk * in the list of sortable fields:

Sorting models

SortableTrait adds a sorted() scope to the model - you can pass it a query being an array of sorting conditions:

or it will use sort parameter from the request as default:

Overwriting default sorting logic

It is possible to overwrite how sorting parameters are used and applied to the query by implementing a callback in your model named sortFieldName, e.g.:

Defining default sorting criteria

It is possible to define default sorting criteria that will be used if no sorting criteria are provided in the request or passed to sorted method of your model. Default sorting criteria should be defined in $defaultSortCriteria property, e.g.:

Defining default sorting order

By default asc is considered as default sorting order. It is possible to define default sorting order that will be used if no sorting order is provided in the request or passed to sorted method of your model. Default sorting order should be defined in $defaultSortOrder property, e.g.:

Additional configuration

If you are using sort request parameter for other purpose, you can change the name of the parameter that will be interpreted as sorting criteria by setting a $sortParameterName property in your model, e.g.:


All versions of sortable with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version *
illuminate/support Version *
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 jedrzej/sortable contains the following files

Loading the files please wait ....