{"id":19258919,"url":"https://github.com/lassehaslev/laravelsortable","last_synced_at":"2026-06-22T12:31:44.513Z","repository":{"id":57012587,"uuid":"74752091","full_name":"LasseHaslev/LaravelSortable","owner":"LasseHaslev","description":"Sorting logic for Laravel models","archived":false,"fork":false,"pushed_at":"2016-11-28T17:41:14.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T18:16:57.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LasseHaslev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-25T11:13:57.000Z","updated_at":"2016-11-28T17:52:48.000Z","dependencies_parsed_at":"2022-08-21T15:10:35.839Z","dependency_job_id":null,"html_url":"https://github.com/LasseHaslev/LaravelSortable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/LasseHaslev/LaravelSortable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2FLaravelSortable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2FLaravelSortable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2FLaravelSortable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2FLaravelSortable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LasseHaslev","download_url":"https://codeload.github.com/LasseHaslev/LaravelSortable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2FLaravelSortable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260920335,"owners_count":23082963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T19:14:47.446Z","updated_at":"2025-11-09T13:03:04.040Z","avatar_url":"https://github.com/LasseHaslev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lassehaslev/laravel-sortable\n\u003e Add sorting logic to your eloquent models\n\n## Install\nRun\n```\ncomposer require lassehaslev/laravel-sortable\n```\n\nCreate your package and add the following line to ```providers``` in ```config/app.php``` \n```\n    LasseHaslev\\LaravelSortable\\Providers\\ServiceProvider::class,\n```\n\n## Usage\nInclude ```LasseHaslev\\LaravelSortable\\Traits\\Sortable``` to models to make it sortable\n```php\n\u003c?\n\nclass TestObject extends Illuminate\\Database\\Eloquent\\Model {\n    use LasseHaslev\\LaravelSortable\\Traits\\Sortable;\n}\n```\n\nYou can also overwrite the column name that holds the sorting value\n```php\n\u003c?\n\nclass TestObject extends Illuminate\\Database\\Eloquent\\Model {\n    use LasseHaslev\\LaravelSortable\\Traits\\Sortable;\n    protected $sortingColumnName = 'order'; // Default\n}\n```\n\n#### Api\n```php\n// Get sorted list\n$sortedCollection = Object::sorted()-\u003eall();\n\n// Move object to position\nObject::moveTo( $objectToMove, $position );\n\n// Move to front\nObject::moveToFront( $objectToMove );\n\n// Move to back\nObject::moveToBack( $objectToMove );\n\n// Increment position by one\nObject::incrementPosition( $objectToMove );\n\n// Decrement position by one\nObject::decrementPosition( $objectToMove );\n```\n\n\n\n## Development\n\n```bash\ncomposer install\nyarn\n```\n\n\n#### Runing tests\n``` bash\n# Run one time\nnpm run test\n\n# Automaticly run test on changes\nnpm run dev\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flassehaslev%2Flaravelsortable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flassehaslev%2Flaravelsortable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flassehaslev%2Flaravelsortable/lists"}