← ClaudeAtlas

laravel-datatables-modulelisted

Builds server-side Yajra DataTables CRUD list modules in Laravel admin apps. Use when adding index pages with AJAX tables, filters, action columns, or migrating modal CRUD to separate index/create/edit pages.
Yaz-inc/yazinc-ai-toolkit · ★ 0 · AI & Automation · score 60
Install: claude install-skill Yaz-inc/yazinc-ai-toolkit
# Laravel DataTables Module (Yajra) Server-side DataTables pattern for Laravel 10 admin panels with jQuery and Bootstrap. ## When to use - New module needs a sortable, searchable list with server-side pagination - Replacing modal CRUD with dedicated pages - Adding filter dropdowns that reload the table via AJAX ## Stack - Laravel 10, PHP 8.1+ - `yajra/laravel-datatables-oracle` (^10) - jQuery + DataTables 1.13.x CDN - Shared layout partial for `window.datatableDefaultConfig` ## Do - Use **separate pages**: `index` (table), `create`, `edit` — not modals for standard CRUD - Detect AJAX in controller: `$request->ajax() || $request->has('draw')` - Eager-load relations in the query; use `withCount` when needed - Put HTML action buttons in `->addColumn('actions', ...)` and list in `->rawColumns(['actions'])` - Gate action buttons by permission in the column callback - Merge page config with `Object.assign({}, window.datatableDefaultConfig || {}, { ... })` - Pass filter values in DataTables `ajax.data` callback ## Don't - Don't return the full view on AJAX requests - Don't forget CSRF on delete forms submitted via JS - Don't hardcode permission checks only in the view — mirror in controller actions column ## Controller pattern ```php public function index(Request $request) { if ($request->ajax() || $request->has('draw')) { $query = Item::with(['category'])->query(); if ($request->filled('filter_status')) { $query->where('status_id', $reque