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

Column Sortable Laravel Package

kyslik/column-sortable

Add sortable table columns to Laravel 5.5–8. Generate clickable links in Blade, configure sortable fields and icons, and sort by related hasOne/belongsTo attributes or withCount(). Works seamlessly with pagination and query building.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature Development: Enables seamless column sorting in Laravel-based admin dashboards, data tables, or reporting tools without reinventing the wheel. Reduces backend complexity for sorting logic by abstracting it into a reusable trait.
  • Roadmap Prioritization: Justifies investing in UI/UX improvements for data-heavy applications (e.g., SaaS admin panels, analytics tools) where sorting is a core user need.
  • Build vs. Buy: Eliminates the need to build custom sorting middleware or query builders, saving dev time and reducing technical debt. Ideal for projects where sorting is a secondary but critical feature.
  • Use Cases:
    • Admin Panels: Sort users, orders, or content by any column (e.g., created_at, status).
    • E-Commerce: Sort products by price, rating, or name dynamically.
    • Analytics Tools: Enable users to reorder data tables (e.g., sales reports) via URL parameters.
    • Legacy System Modernization: Add sorting to existing Laravel apps with minimal refactoring.

When to Consider This Package

  • Adopt if:

    • Your Laravel app requires column sorting in data tables (e.g., admin panels, reports).
    • You need URL-based sorting (e.g., /users?sort=name:desc) for bookmarkable, shareable links.
    • Your team lacks time/resources to build custom sorting logic (e.g., handling orderBy for nested relations).
    • You’re using Laravel 9–13 (active maintenance) and need Font Awesome 5/4 compatibility.
    • Your models have complex relations (e.g., hasOne, belongsTo) that require sorting.
  • Look elsewhere if:

    • You need client-side sorting (e.g., JavaScript-based tables like DataTables). This package is server-side only.
    • Your app uses non-Laravel frameworks (e.g., Symfony, Django).
    • You require multi-column sorting (e.g., sort by name and date). This package handles single-column sorting per request.
    • Your database schema is highly dynamic (e.g., columns added/removed at runtime). The package assumes static $sortable arrays.
    • You’re on Laravel <9 or PHP <8.0 (unsupported in latest versions).

How to Pitch It (Stakeholders)

For Executives: "This package lets us add column sorting to our Laravel admin dashboard with zero backend development—users can click headers to sort data (e.g., ‘Newest First’ or ‘Price: Low to High’), and the URL updates automatically. This improves usability for power users (e.g., support teams, analysts) without adding technical risk. It’s battle-tested (600+ stars), MIT-licensed, and maintained for Laravel 9–13. Implementation takes <1 hour and saves us from building custom sorting logic."

For Engineers: *"Pros:

  • Trait-based: Add use Sortable to any Eloquent model and define $sortable = ['column1', 'column2']—done.
  • Relation Support: Sort by related tables (e.g., user.detail.phone_number) with minimal config.
  • URL-Friendly: Sorting persists in links (e.g., /orders?sort=total:desc), enabling sharing/bookmarking.
  • Blade Helper: @sortablelink('column', 'Label') generates sortable headers with icons (Font Awesome).
  • Performance: Avoids Schema::hasColumn() checks if $sortable is defined.

Cons:

  • No multi-column sorting (but covers 90% of use cases).
  • Requires manual relation definitions for complex joins.

Quick Start:

  1. composer require kyslik/column-sortable
  2. Add use Sortable; to your model and define $sortable = ['id', 'name'].
  3. Use $model->sortable()->paginate(10) in controllers.
  4. Add @sortablelink('name', 'Name') to Blade views.

Alternatives: If you need client-side sorting, pair this with a JS library like DataTables. For multi-column sorting, consider building a custom solution."*

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4