Download the PHP package pion/laravel-eloquent-position without Composer

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

Laravel eloquent model position

Total Downloads Latest Stable Version Latest Unstable Version

Position logic for Eloquent models with minimum setup. Before saving it will check if the position has changed and updates the other entries based on the models position value.

Installation

Tested in Laravel 5.4 - 8.

Install via composer

Usage

  1. Add a position (can be custom) column in your table (model)
  2. Add PositionTrait into your model (if you are using custom column set the $positionColumn property)
  3. If you are using grouped entries (like parent_id and etc), you can set the $positionGroup with the column name/names (supports single string or multiple columns)
  4. Add to form the position input (can be input[type=number] and etc) and fill/set the position on save
  5. When position is null or empty string, the last position will be used.
  6. If you are not using migration (the column exists), run the php artisian model:position` command to fix current entries (it will create correct order)

Then you can get your entries sorted:

If using default column name (position), the value will be converted to numeric value (if not null or empty string).

Get the position Use the $model->getPosition() or use the standard way by using the column name $model->position

Migration example

Model example

Events

You can listen to events for positioning changes. You can use the PositionEventsTrait for easy model registration.

Positioning

Called before running the last position calculation and the final movement of other entries for given position.

Enables to:

Name: positioning

Positioned

Name: positioned

Example via trait:

Command

Reposition command

This command will help you to fix the order of your models. You must provide a model class. You must include the RecalculatePositionCommand into your Console Kernel class.

Traits

PositionTrait

Uses the BasePositionTrait and PositionScopeTrait

You can set:

PositionScopeTrait

Todo

Contribution

See CONTRIBUTING.md for how to contribute changes. All contributions are welcome.

Copyright and License

laravel-eloquent-position was written by Martin Kluska and is released under the MIT License.

Copyright (c) 2016 Martin Kluska


All versions of laravel-eloquent-position with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version >=5.5
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 pion/laravel-eloquent-position contains the following files

Loading the files please wait ....