Download the PHP package chandra-hemant/server-side-datatable without Composer
On this page you can find all versions of the php package chandra-hemant/server-side-datatable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chandra-hemant/server-side-datatable
More information about chandra-hemant/server-side-datatable
Files in chandra-hemant/server-side-datatable
Package server-side-datatable
Short Description A laravel package for Server Side Datatable helpers
License MIT
Informations about the package server-side-datatable
Server Side Data Table Packages
This package provides convenient methods to fetch data for server-side DataTables in Laravel applications with multiple approaches ranging from simple to advanced usage.
Installation
You can install this package via Composer:
Overview
The ChandraHemant/ServerSideDatatable package provides helper methods for retrieving data from database tables with options to join multiple tables, apply complex conditions, and handle server-side processing for DataTables in Laravel applications.
Namespace: ChandraHemant\ServerSideDatatable
Author: Hemant Kumar Chandra
🚀 FlexibleDataTable Class (Recommended)
NEW: The most developer-friendly approach with Laravel-style fluent interface!
Features
✅ Laravel-Style Fluent Interface - Method chaining just like Eloquent
✅ All Laravel Query Builder Methods - where, whereIn, whereRaw, join, etc.
✅ Zero Learning Curve - If you know Laravel, you know this!
✅ Case-Insensitive Search - Works with both English and Hindi text
✅ Auto DataTable Formatting - Returns proper DataTable JSON response
✅ Multiple Output Formats - DataTable, Collection, or Query Builder
✅ IntelliSense Support - Full IDE auto-completion
✅ Magic Method Support - Automatically supports current and future Laravel functions
Quick Start
Basic Usage
Advanced Usage
Different Output Formats
Helper Methods
Controller Example
Available Methods
Core Methods
of(Model $model)- Create new instancemake()- Return DataTable JSON responseget()- Return Collection of modelsgetQuery()- Return Query Builder instance
Search Configuration
searchable(array $columns)- Set searchable columnssearchableRelation(string $relation, array $columns)- Add searchable relationshiporderable(array $columns)- Set orderable columns
Laravel Query Builder Methods (All Supported!)
- Basic:
where,whereIn,whereNotIn,whereNull,whereNotNull - Date/Time:
whereDate,whereMonth,whereYear,whereTime,whereBetween - Raw Queries:
whereRaw,selectRaw,orderByRaw,havingRaw - Relationships:
whereHas,whereDoesntHave,whereRelation,whereBelongsTo - Joins:
join,leftJoin,rightJoin,crossJoin - Aggregates:
groupBy,having,withCount,withSum,withAvg - Advanced:
when,unless,tap,distinct,limit,offset - JSON:
whereJsonContains,whereJsonLength,whereJsonPath - Subqueries:
whereExists,whereInwith closures - Model Scopes: Custom scopes from your models
Helper Methods
when(condition, callback)- Conditional query buildingprofitLoss(profitColumn, lossColumn, searchValue)- Profit/loss filteringfilterByYear(column, year)- Year-based filtering
DynamicModelDataTableHelper Class
The DynamicModelDataTableHelper class provides advanced server-side DataTable functionality with complex array-based configuration. This is the most powerful but complex approach.
Usage
Retrieving Data
Complex Nested Conditions
Constructor Parameters
$eloquentModel(Illuminate\Database\Eloquent\Model): The Eloquent model to query for data.$dynamicConditions(array): An array specifying the dynamic conditions for the query.$searchColumns(array): An array specifying columns to search in.$searchRelationships(array): An array specifying relationships to search in.
Methods
getServerSideDataTable(bool $query = false)- Retrieve server-side DataTables datacountFilteredServerSideDataTable()- Count filtered records
DataTableHelper Class
The DataTableHelper class provides traditional SQL-based server-side data retrieval for DataTables with support for complex joins and raw SQL queries.
Methods
getServerSideDataTable($column, $join = array())- Retrieves data with joinscountFilteredServerSideDataTable($column, $join = array())- Counts filtered rowsgetDataWithJoinTables($column, $join = array())- Retrieves data with joins (no pagination)
Usage Example
ModelDataTableHelper Class
This class provides Eloquent model-based server-side DataTables functionality with advanced column configuration and relationship handling.
Usage Example
Comparison of Approaches
| Feature | FlexibleDataTable | DynamicModelDataTableHelper |
|---|---|---|
| Ease of Use | ⭐⭐⭐⭐⭐ Very Easy | ⭐⭐ Complex |
| Learning Curve | ⭐⭐⭐⭐⭐ Zero (Laravel-like) | ⭐⭐ High |
| Flexibility | ⭐⭐⭐⭐⭐ Very High | ⭐⭐⭐⭐⭐ Very High |
| Laravel Integration | ⭐⭐⭐⭐⭐ Perfect | ⭐⭐⭐⭐ Good |
| Code Readability | ⭐⭐⭐⭐⭐ Excellent | ⭐⭐ Poor |
| Performance | ⭐⭐⭐⭐⭐ Excellent | ⭐⭐⭐⭐ Good |
Recommendations
- 🚀 For New Projects: Use FlexibleDataTable - Laravel-style, easy to learn and use
- 🔧 For Complex Legacy Systems: Use DynamicModelDataTableHelper - Maximum flexibility with array configuration
- 📊 For Raw SQL Needs: Use DataTableHelper - Direct SQL control with joins
- ⚡ For Eloquent-Heavy Apps: Use ModelDataTableHelper - Good balance of features and complexity
Important Notes
Column Order Consistency
Maintaining consistency in the order and length between the orderable array and Table Headers is crucial for ensuring accurate column sorting in DataTables. The order of elements in the orderable array must align with the headers of the corresponding table.
Case-Sensitive Search
For case-insensitive search functionality, ensure your database collation supports it, or use the built-in LOWER() function implementation in FlexibleDataTable.
Performance Optimization
- Add database indexes for searchable and orderable columns
- Use
select()to limit retrieved columns - Consider caching for frequently accessed data
- Monitor query performance in production
License
This package is open-sourced software licensed under the MIT license.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or have questions, please open an issue on GitHub.