Download the PHP package flyhjaelp/laravel-eloquent-orderable without Composer

On this page you can find all versions of the php package flyhjaelp/laravel-eloquent-orderable. 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-eloquent-orderable

Laravel Eloquent Orderable

Laravel Eloquent Orderable is a package that helps you make your eloquent models orderable, either within a group our within all other models of the same class.

Installation

Install via composer

Database setup

If you want to use the orderable functionality on a model it has to have a database column it can be ordered by. By default the package will look for a column named "order", but this can be overwritten. The order column should be an unsigned integer that's nullable. Example:

Default Usage

Creating a new model without a specified order

New instances will now have an order added to them, by default they are added as last in order.

Creating a new model with a specified order

If an order is specified when being created that order will update already existing orders accordingly.

Updating the order of a model

When updating a models order the other models automatically update their orders accordingly.

Deleting a model

When deleting a model, the order of all other models with a higher order will have their order decreased by one.

Grouping usage

You can make a group within your model, and the order only applies within the group. Example you might have a model called MenuItem which should be grouped by menu_id, and the order should only apply within it's group. To add a group to model you have to include the orderableWithinGroup trait and implement the following functions:

Models are now ordered within their group

New instances will have an order added to them, by default they are added as last in order within their group

Usage within pivot models

You can make pivot models orderable if you wish to be able order a many to many relationship whenever it's retrieved. The order only works one way, meaning if you for example have a journey that has mutiple checkpoints you can make the checkpoints come in the correct order when you retrieve them from the journey, but not the other way around.

Setup pivot model ordering

For a pivot model to be orderable you have to use the PivotOrderable trait on the model. It's also required to have an autoincrementing primary key(usually an "id") in the pivot relationship table. Besides that you have to implement the methods mentioned under OrderableWithinGroup

When calling the relationship from a model, you have to chain on the using method on the belongsToMany call when defining the relationship on the model. Also you have to add orderBy method call if you want the relationship ordered when retrieved.

Overwriting default values

You have to change the default column used for storing the order in, as well as the default ordering scope.

Overwriting default ordering column

Overwriting global ordering scope

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT


All versions of laravel-eloquent-orderable with dependencies

PHP Build Version
Package Version
No informations.
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 flyhjaelp/laravel-eloquent-orderable contains the following files

Loading the files please wait ....