Download the PHP package hippieua/laravel-sortablev2 without Composer
On this page you can find all versions of the php package hippieua/laravel-sortablev2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hippieua/laravel-sortablev2
More information about hippieua/laravel-sortablev2
Files in hippieua/laravel-sortablev2
Package laravel-sortablev2
Short Description Trait to sort order in Laravel model
License MIT
Homepage https://github.com/hippieua/laravel-sortablev2
Informations about the package laravel-sortablev2
Laravel Sortable v2
Laravel Sortable v2 is a Laravel package designed to easily add sortable behavior to Eloquent models. This package allows you to manage the order of database records via simple trait inclusion.
Features
- Sortable Trait: Include a trait in your Eloquent models to enable sortable functionality.
- Automatic Order Management: Automatically manages the order field during creation and provides methods to move records up or down.
- Relation Support: Handles sorting within the context of a parent relationship, ideal for nested resources or grouped items.
Installation
To install the package, run the following command in your Laravel project:
Usage
Setup
-
Make migration to add sortable field to your model
-
Include the Trait in Your Model
- Define Sortable Field and Optional Relation
Override methods in your model if you need a custom sortable field or a specific relation for sorting:
Managing Order
-
Move an Item Up
- Move an Item Down
Events
The package hooks into several Eloquent model events to ensure data integrity:
creating
saving
updating
deleting
retrieved
- Conditionally
restoring
if SoftDeletes is used.
Requirements
- PHP >= 8.0
- Laravel 9.x to 11.x
Contributing
Contributions are welcome, and any issues or pull requests should be submitted on the GitHub repository.
License
The Laravel Sortable v2 package is open-sourced software licensed under the MIT license.