Download the PHP package sudo520/laravel-sortable without Composer

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

Make your Laravel models Sortable in a moment

There are lots of situations when you need a sorting functionality for your models. Of course everyone wants simple package to cover all common use cases.

Know what? You've found it!

This package will automatically apply sort index for your newly created models, and also handle all resorting stuff.

Installation

You can install this package using composer. Just run a command bellow.

Usage

It's very easy to start with this package. Just use Sudo520\LaravelSortable\Sortable trait in your model, and add sort_index column in your models migration and into $fillable property.

But of course every cool package should be configurable. This one is too :)

Configurations

So if you want to change the sorting column (by default it is sort_index), you should set a $sortIndexColumn property in your model.

How I've mentioned above your newly created model will be sorted automatically, but in case you don't want it, you always can set property $setSortIndexOnCreating to false

Let's imagine a situation, when you have Users and every user has many Posts. In this kind of situation if you would like to add sorting for Posts, it will be weird to sort all Posts together, of course you will want to sort them for each user (grouped by user_id).

It can be easily done by setting $sortingParentColumn property of your model name of the column by which you want to group your sorting. And your newly created Posts now will be sorted uniquely for their user.

You also can configure start index of your models sorting, by default it will start from 1. To change it you should set $startSortingFrom property the number from which you want to start sorting.

Helpful stuff

Simple but useful scopes

Trait also will add some functionality to your models. For example, if you want get your models sorted, just apply sorted scope on your models.

Also you can use sortedDesc scope, which how you have guessed will order models in descending order.

Methods

Be sure this methods will make your life easier.

If you have two models and want to swap them use swapSort method:

In order to manipulate your one model's sorting you can use those methods:

And of course you can just update your model's property, which is responsible for sort index and all other entities will be reordered automatically.

Conclusions

It's a lightweight, easy to use package which you can easily integrate into your application. Feel free to report about issues and possible improvements.

Thank you!


All versions of laravel-sortable with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
laravel/framework Version ^9.0|^10.0|^11.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 sudo520/laravel-sortable contains the following files

Loading the files please wait ....