- How do I integrate this package with Laravel 12+ for server-side DataTables?
- Install via Composer (`composer require yajra/laravel-datatables-html:^13`), then use `DataTables::of(YourModel::query())->html()` in your controller. The package handles server-side processing with Eloquent, eliminating client-side bottlenecks for large datasets.
- Does this work with Livewire for real-time updates?
- Yes. Call `Builder::useLivewire()` in your `AppServiceProvider` and use `Builder::of(YourModel::query())->livewire()` in your Livewire component. This enables features like search-as-you-type without page reloads.
- How do I configure Vite asset handling for DataTables?
- Set `Builder::useVite()` in your `AppServiceProvider` to output ES modules. Ensure your Vite config includes DataTables JS from npm (`@datatables.net`). The package generates Vite-compatible script tags automatically.
- What Laravel versions are officially supported?
- The package supports Laravel 8–13, with version-specific branches (e.g., `^13` for Laravel 12/13). Check the [compatibility table](https://github.com/yajra/laravel-datatables-html#laravel-version-compatibility) to match your LTS version.
- Can I customize column visibility based on user roles?
- Yes. Use `visibleIf()` with Laravel’s gates or policies, e.g., `->column('salary', 'Salary')->visibleIfCan('view_salary')`. This integrates seamlessly with Laravel’s authorization system.
- How do I handle large datasets (e.g., 50K+ records) efficiently?
- Optimize with Laravel’s query caching (`->remember()`) or database indexing. For extreme cases, use `->select()` to limit loaded columns. The package streams data server-side, but complex queries may need profiling.
- What if I need custom DataTables plugins (e.g., row grouping)?
- Use `addScript()` or `addScriptIfCannot()` to load custom JS. For advanced plugins, ensure compatibility with your Vite/Livewire setup. The package’s fluent API lets you inject any DataTables initialization code.
- Is there a Blade directive for quick table rendering?
- Yes. Use `@datatables.table(['table' => 'users'])` in your Blade views. This shortcut generates the full HTML/JS markup, but you can also use `Builder::table()` in PHP for more control.
- How do I avoid duplicate script loading in production?
- Use `Builder::addScriptIfCannot()` to conditionally load scripts. For Vite, ensure DataTables is only imported once in your entry file. The package checks for existing scripts by default.
- What are the alternatives if I need RTL or multi-language support?
- The package supports DataTables’ built-in JS i18n (e.g., `Builder::language('ar')`). For RTL, use DataTables’ RTL CSS and override Blade templates with `getTemplate()`. Localization is handled via JS, not PHP.