Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sortable Laravel Package

jedrzej/sortable

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • User Experience (UX) Enhancements: Enable intuitive, dynamic sorting of lists (e.g., dashboards, admin panels, or public-facing content) via URL parameters (e.g., ?sort=created_at:desc), reducing client-side JavaScript complexity.
  • API Consistency: Standardize sorting behavior across Eloquent models in a Laravel backend, ensuring uniformity in both web and API responses.
  • Roadmap for "Pimpable" Ecosystem: Adopt this as a foundational piece to later integrate Searchable and Withable traits, creating a unified data-fetching pipeline (sort/filter/eager-load) with minimal boilerplate.
  • Build vs. Buy: Avoid reinventing sorting logic (e.g., manual query builder manipulation) while maintaining control over implementation details (e.g., customizing default sort fields or validation).
  • Use Cases:
    • Admin panels (e.g., sorting users by last_login_at or role).
    • Public content (e.g., blog posts by popularity or date).
    • API-driven frontends (e.g., React/Vue apps consuming Laravel APIs with dynamic sorting).

When to Consider This Package

  • Adopt When:
    • Your Laravel app relies on Eloquent for data access and needs consistent, declarative sorting across multiple models.
    • You want to expose sorting via URL parameters (e.g., for SEO-friendly links or API endpoints) without heavy frontend logic.
    • Your team prefers traits over middleware/services for lightweight, model-specific behavior.
    • You’re already using or plan to use Jedrzej’s Searchable/Withable traits for a cohesive data-fetching system.
  • Look Elsewhere If:
    • You need complex multi-column sorting (e.g., SQL ORDER BY FIELD() or custom expressions)—this package supports basic field:direction syntax only.
    • Your app uses non-Eloquent data sources (e.g., raw SQL queries, third-party APIs).
    • You require real-time sorting (e.g., WebSockets) or client-side sorting (e.g., DataTables)—this is server-side only.
    • Your team prefers explicit query builder methods over trait-based magic (e.g., Model::orderBy($request->sort)).
    • You’re using Laravel 7+ (this package is unmaintained; consider alternatives like spatie/laravel-query-builder or custom solutions).

How to Pitch It (Stakeholders)

For Executives: "This package lets us add sorting to any database list—like a user dashboard or product catalog—with a single line of code. Users can sort by clicking columns (e.g., ‘Newest First’) or via URL parameters (e.g., /posts?sort=views:desc), improving usability without extra frontend work. It’s lightweight, open-source, and integrates with our existing Laravel backend. The long-term benefit? We can scale this to filtering and eager-loading later, reducing dev time for future features."

For Engineering: *"The SortableTrait automates Eloquent orderBy logic based on request params (e.g., ?sort=price:asc). Key perks:

  • Zero boilerplate: Define sortable fields once (e.g., $sortable = ['name', 'created_at']) and let the trait handle the rest.
  • API-friendly: Works seamlessly with Laravel APIs (e.g., Accept: application/json requests).
  • Extensible: Override getSortableAttributes() for dynamic rules (e.g., sort by user.role only for admins).
  • Complements existing tools: Pairs well with Searchable (filtering) and Withable (eager loading) for a unified data pipeline. Tradeoff: Unmaintained for Laravel 7+, but the code is simple enough to fork if needed. Alternatives like spatie/laravel-query-builder offer more features but require more setup."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui