{"id":32610531,"url":"https://github.com/maize-tech/laravel-nova-eloquent-sortable","last_synced_at":"2025-10-30T13:50:16.520Z","repository":{"id":61181836,"uuid":"549021860","full_name":"maize-tech/laravel-nova-eloquent-sortable","owner":"maize-tech","description":"Add sortable actions to any resource in Laravel Nova","archived":false,"fork":false,"pushed_at":"2025-08-11T17:26:51.000Z","size":3739,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-05T04:13:57.062Z","etag":null,"topics":["field","laravel","nova","sortable","sorting"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maize-tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"maize-tech"}},"created_at":"2022-10-10T14:51:14.000Z","updated_at":"2025-07-28T16:23:01.000Z","dependencies_parsed_at":"2023-02-01T02:45:29.895Z","dependency_job_id":"1b33ec82-d9d8-419e-bfb6-19debc91e915","html_url":"https://github.com/maize-tech/laravel-nova-eloquent-sortable","commit_stats":{"total_commits":19,"total_committers":4,"mean_commits":4.75,"dds":0.5263157894736843,"last_synced_commit":"3edba46bc32f9c0e24523c8b7db2dca6c68ebdfc"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/maize-tech/laravel-nova-eloquent-sortable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-nova-eloquent-sortable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-nova-eloquent-sortable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-nova-eloquent-sortable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-nova-eloquent-sortable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maize-tech","download_url":"https://codeload.github.com/maize-tech/laravel-nova-eloquent-sortable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-nova-eloquent-sortable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281818074,"owners_count":26566858,"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","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["field","laravel","nova","sortable","sorting"],"created_at":"2025-10-30T13:50:14.635Z","updated_at":"2025-10-30T13:50:16.510Z","avatar_url":"https://github.com/maize-tech.png","language":"PHP","funding_links":["https://github.com/sponsors/maize-tech"],"categories":[],"sub_categories":[],"readme":"# Laravel Nova Eloquent Sortable\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/maize-tech/laravel-nova-eloquent-sortable.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-nova-eloquent-sortable)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-nova-eloquent-sortable/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/maize-tech/laravel-nova-eloquent-sortable/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-nova-eloquent-sortable/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/maize-tech/laravel-nova-eloquent-sortable/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/maize-tech/laravel-nova-eloquent-sortable.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-nova-eloquent-sortable)\n\nEasily add inline sortable actions to any resource in Laravel Nova.\n\n\u003eThis package is heavily based on Spatie's [Eloquent Sortable](https://github.com/spatie/eloquent-sortable).\n\u003ePlease make sure to read its documentation and installation guide before proceeding!\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"/art/preview.gif\" alt=\"Laravel Nova Eloquent Sortable in action\"\u003e\u003c/p\u003e\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require maize-tech/laravel-nova-eloquent-sortable\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"nova-eloquent-sortable-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | See sortable action permission\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the fully qualified class name of the invokable class\n    | used to determine whether a user can see sortable actions or not.\n    | If null, all users who have access to Nova will have the permission.\n    |\n    */\n\n    'can_see_sortable_action' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Run sortable action permission\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the fully qualified class name of the invokable class\n    | used to determine whether a user can sort a given model or not.\n    | If null, all users who have access to Nova will have the permission.\n    |\n    */\n\n    'can_run_sortable_action' =\u003e null,\n\n];\n```\n\n## Usage\n\nTo use the package, add the `Maize\\NovaEloquentSortable\\HasEloquentSortable` trait to the nova resource where you want to have marks:\n\n```php\nuse Laravel\\Nova\\Resource;\nuse Maize\\NovaEloquentSortable\\HasEloquentSortable;\n\nclass MyResource extends Resource {\n    use HasEloquentSortable;\n}\n```\n\nOnce done, all you have to do is include all the actions you need for the given resource:\n\n```php\nuse Maize\\NovaEloquentSortable\\Actions\\MoveOrderDownAction;\nuse Maize\\NovaEloquentSortable\\Actions\\MoveOrderUpAction;\nuse Maize\\NovaEloquentSortable\\Actions\\MoveToEndAction;\nuse Maize\\NovaEloquentSortable\\Actions\\MoveToStartAction;\n\npublic function actions(NovaRequest $request)\n{\n    return [\n        MoveOrderDownAction::make(),\n        MoveToEndAction::make(),\n        MoveOrderUpAction::make(),\n        MoveToStartAction::make(),\n    ];\n}\n```\n\nYou can also include the custom OrderColumn field, which allows you to show the order of each entity when indexing them:\n\n```php\nuse Maize\\NovaEloquentSortable\\Fields\\OrderColumn;\n\npublic function fields(NovaRequest $request)\n{\n    return [\n        OrderColumn::new('Order', static::class),\n    ];\n}\n```\n\n## Available Actions\n\n- [`MoveOrderDownAction`](#moveorderdownaction)\n- [`MoveToEndAction`](#movetoendaction)\n- [`MoveOrderUpAction`](#moveorderupaction)\n- [`MoveToStartAction`](#movetostartaction)\n\n### MoveOrderDownAction\n\nThe `MoveOrderDownAction` inline action moves the given model down by a single position.\n\nThe action is automatically hidden when the model is already in the last position.\n\n### MoveToEndAction\n\nThe `MoveToEndAction` inline action moves the given model to the last position.\n\nThe action is automatically hidden when the model is already in the last position.\n\n### MoveOrderUpAction\n\nThe `MoveOrderUpAction` inline action moves the given model up by a single position.\n\nThe action is automatically hidden when the model is already in the first position.\n\n### MoveToStartAction\n\nThe `MoveToStartAction` inline action moves the given model to the first position.\n\nThe action is automatically hidden when the model is already in the first position.\n\n## Define a custom visibility\n\nBy default, all users who have access to Laravel Nova will be able to see all included sort actions.\n\nIf you want to restrict their visibility for some users, you can define a custom `CanSeeSortableAction` invokable class.\n\nHere's an example class checking user's permissions:\n\n```php\nuse Laravel\\Nova\\Http\\Requests\\NovaRequest;\n\nclass CanSeeSortableAction\n{\n    public function __invoke(NovaRequest $request): bool\n    {\n        return $request-\u003euser()-\u003ecan('sort_models');\n    }\n}\n```\n\nOnce done, all you have to do is reference your custom class in `can_see_sortable_action` attribute under `config/nova-eloquent-sortable.php`:\n\n``` php\n'can_see_sortable_action' =\u003e \\Path\\To\\CanSeeSortableAction::class,\n```\n\n## Define a custom run permission\n\nBy default, all users who have access to Laravel Nova will be able to run all included sort actions.\n\nIf you want to restrict the permission for some users, you can define a custom `CanRunSortableAction` invokable class.\n\nHere's an example class checking user's permissions:\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Laravel\\Nova\\Http\\Requests\\NovaRequest;\n\nclass CanRunSortableAction\n{\n    public function __invoke(NovaRequest $request, Model $model): bool\n    {\n        return $request-\u003euser()-\u003ecan('sort_model', $model);\n    }\n}\n```\n\nOnce done, all you have to do is reference your custom class in `can_run_sortable_action` attribute under `config/nova-eloquent-sortable.php`:\n\n``` php\n'can_run_sortable_action' =\u003e \\Path\\To\\CanRunSortableAction::class,\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/maize-tech/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](https://github.com/maize-tech/.github/security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Enrico De Lazzari](https://github.com/enricodelazzari)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaize-tech%2Flaravel-nova-eloquent-sortable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaize-tech%2Flaravel-nova-eloquent-sortable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaize-tech%2Flaravel-nova-eloquent-sortable/lists"}