For AI Agents: Simple, practical guide to using ArtFlow Table in Blade views
The ArtFlow Table is a Livewire datatable component that displays data with automatic:
Version: 1.6.0 | Site: https://artflow.pk
Use it in Blade views with: [@livewire](https://github.com/livewire)('aftable', [...])
[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\Item',
'columns' => [
['key' => 'title', 'label' => 'Item Name'],
['key' => 'code', 'label' => 'Code'],
['key' => 'amount', 'label' => 'Amount'],
],
])
[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\Item', # Your Eloquent model
'records' => 25, # Items per page (default: 50)
'customQuery' => $query, # Optional: custom query builder
'data' => $collection, # Optional: pre-fetched data
])
['key' => 'title', 'label' => 'Item Name']
['key' => 'category_name', 'label' => 'Category', 'relation' => 'category:name']
category.name for each item['key' => 'subitems_count', 'label' => 'Sub-items']
Subitem relationship auto-detected from model_countsubitems() relation, use subitems_count['key' => 'id', 'hidden' => true]
['key' => 'actions', 'raw' => '<button onclick="...">Edit</button>']
[
'key' => 'price',
'label' => 'Price',
'value_type' => 'price' # Formats as $X,XXX.XX
]
[@livewire](https://github.com/livewire)('aftable', [
'tableClass' => 'w-full border-collapse',
'theadClass' => 'bg-gray-100',
'rowClass' => 'hover:bg-gray-50',
])
[@livewire](https://github.com/livewire)('aftable', [
'showPagination' => true, # Show pagination controls
'showSearch' => true, # Show search box
'showColumnVisibility' => true, # Show column toggle
'showExport' => true, # Show export button
])
[@livewire](https://github.com/livewire)('aftable', [
'searchable' => true, # Enable search (default: true)
])
relation)[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\Item',
'columns' => [
['key' => 'title', 'label' => 'Title'],
['key' => 'description', 'label' => 'Description'],
['key' => 'category_name', 'label' => 'Category', 'relation' => 'category:name'],
['key' => 'department_name', 'label' => 'Department', 'relation' => 'department:name'],
],
])
[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\Item',
'columns' => [
['key' => 'title', 'label' => 'Title'],
['key' => 'category_name', 'label' => 'Category', 'relation' => 'category:name'],
['key' => 'department_name', 'label' => 'Department', 'relation' => 'department:name'],
['key' => 'supplier_name', 'label' => 'Supplier', 'relation' => 'supplier:name'],
],
])
What Happens:
Relationship Format: 'relation' => 'relationName:columnName'
relationName = method name on model (e.g., category())columnName = column to display (e.g., name)[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\Item',
'columns' => [
['key' => 'title', 'label' => 'Title'],
['key' => 'subitems_count', 'label' => 'Sub-items'],
['key' => 'related_count', 'label' => 'Related Items'],
['key' => 'attachments_count', 'label' => 'Attachments'],
],
])
What Happens:
_count suffixsubitems, related, attachmentswithCount() to queryRules:
relationName_countsubitems() → use subitems_count[
'key' => 'actions',
'label' => 'Actions',
'actions' => [
[
'type' => 'button',
'label' => 'Edit',
'href' => '/items/{id}/edit',
'class' => 'btn btn-primary btn-sm',
],
[
'type' => 'button',
'label' => 'Delete',
'href' => '/items/{id}',
'method' => 'DELETE',
'confirm' => 'Are you sure?',
'class' => 'btn btn-danger btn-sm',
],
]
]
[
'type' => 'toggle',
'label' => 'Active',
'href' => '/items/{id}/toggle-active',
'method' => 'POST',
'activeExpression' => 'is_active === true',
'activeClass' => 'bg-green-500',
'inactiveClass' => 'bg-red-500',
]
[
'type' => 'raw',
'content' => '<span class="badge">{{ status }}</span>',
]
[@livewire](https://github.com/livewire)('aftable', [
'showExport' => true,
'exportFormats' => ['csv', 'excel', 'pdf'],
])
User clicks Export button → Downloads file → Done!
[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\Item',
'records' => 50,
'columns' => [
['key' => 'id', 'label' => 'ID', 'hidden' => true],
['key' => 'title', 'label' => 'Item Name'],
['key' => 'code', 'label' => 'Code'],
['key' => 'category_name', 'label' => 'Category', 'relation' => 'category:name'],
['key' => 'supplier_name', 'label' => 'Supplier', 'relation' => 'supplier:name'],
['key' => 'amount', 'label' => 'Amount', 'value_type' => 'price'],
['key' => 'subitems_count', 'label' => 'Sub-items'],
['key' => 'quantity', 'label' => 'Quantity'],
[
'key' => 'actions',
'label' => 'Actions',
'actions' => [
['type' => 'button', 'label' => 'Edit', 'href' => '/items/{id}/edit', 'class' => 'btn btn-sm'],
['type' => 'button', 'label' => 'Delete', 'href' => '/items/{id}', 'method' => 'DELETE', 'confirm' => 'Sure?'],
]
],
],
])
[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\User',
'records' => 25,
'columns' => [
['key' => 'name', 'label' => 'Name'],
['key' => 'email', 'label' => 'Email'],
['key' => 'department_name', 'label' => 'Department', 'relation' => 'department:name'],
['key' => 'organization_name', 'label' => 'Organization', 'relation' => 'organization:name'],
['key' => 'is_active', 'label' => 'Status', 'value_type' => 'boolean'],
['key' => 'created_at', 'label' => 'Joined', 'value_type' => 'date'],
[
'key' => 'actions',
'label' => '',
'actions' => [
['type' => 'toggle', 'label' => 'Active', 'href' => '/users/{id}/toggle', 'method' => 'POST', 'activeExpression' => 'is_active === true'],
]
],
],
])
Problem: [@livewire](https://github.com/livewire)('aftable', [...] doesn't work
Solution: Make sure package is installed: composer require artflow-studio/table
Problem: Column headers not sortable Solution: Ensure column is a database field (not a formula). Sorting only works on actual database columns.
Problem: Search returns no results Solution: Make sure you're searching text columns. Numbers, dates, and boolean fields won't search.
Problem: Slow loading, many queries in DevTools
Solution: Use 'relation' for related data (e.g., 'relation' => 'category:name')
Problem: Relationship column shows blank/null Solution:
category() method exists on model)category.name exists)'relation' => 'category:name'Problem: Counts wrong Solution:
_count suffixvariants() relation, column must be variants_count'relation' => 'relationName:columnName' for related datacolumnName_count for relationship counts'hidden' => true for ID columns you don't need to show'key' (must be database fields)'raw' HTML unless you control the content (XSS risk)When an AI needs to use ArtFlow Table:
Identify the Model
Product, User)List Needed Fields
name, email)Identify Relationships
category, brand)'relation' => 'relationName:columnName'Check for Counts
columnName_count (e.g., variants_count)Add Actions
Render in Blade
[@livewire](https://github.com/livewire)('aftable', [
'model' => 'App\Models\YourModel',
'columns' => [...all columns...],
])
Q: Can I use this in a Livewire component? A: No, only in Blade views. The component IS the Livewire component.
Q: How many records can it handle? A: Tested with 1M+ records. Pagination keeps it fast.
Q: Can I customize the appearance? A: Yes, use Tailwind CSS classes. See "Styling" section.
Q: Is it real-time? A: Yes! Livewire makes it reactive. Changes update instantly.
Q: Can I add custom filters? A: Yes, advanced filters available. See advanced guide.
Q: How do I handle soft deletes?
A: Use withTrashed() or onlyTrashed() in custom query.
That's it! You now have a fully-featured datatable with sorting, searching, pagination, and more!
Version: 1.6.0
Last Updated: July 2025
For: AI Agents & Developers
Status: Production Ready ✅
Pass any PHP array or Laravel Collection — no Eloquent model needed:
[@php](https://github.com/php)
$employees = [
['name' => 'Alice', 'dept' => 'Engineering', 'salary' => 5000],
['name' => 'Bob', 'dept' => 'Design', 'salary' => 4500],
];
[@endphp](https://github.com/endphp)
[@livewire](https://github.com/livewire)('aftable', [
'data' => $employees,
'vars' => ['currency' => 'USD'],
'columns' => [
['key' => 'name', 'label' => 'Name'],
['key' => 'dept', 'label' => 'Department'],
['key' => 'salary', 'label' => 'Salary',
'raw' => '{{ $currency }} {{ number_format($row->salary, 2) }}'],
],
])
[@livewire](https://github.com/livewire)('aftable', [
'model' => App\Models\User::class,
'vars' => ['currency' => 'USD'],
'columns' => [
['key' => 'name', 'label' => 'Name'],
// Closure receives ($row, $vars)
['key' => 'status', 'label' => 'Status',
'raw' => fn($row) => $row->active
? '<span class="badge bg-success">Active</span>'
: '<span class="badge bg-danger">Inactive</span>'],
['key' => 'salary', 'label' => 'Salary',
'raw' => fn($row, $vars) => e($vars['currency']).' '.number_format($row->salary, 2)],
],
])
[@aftable](https://github.com/aftable) / [@endaftable](https://github.com/endaftable)Wrap your own <table> markup to apply your app's theme to the table:
[@aftable](https://github.com/aftable)(['model' => App\Models\User::class, 'columns' => [
['key' => 'name', 'label' => 'Name'],
['key' => 'email', 'label' => 'Email'],
]])
<table class="table table-hover table-striped my-theme">
<thead class="bg-dark text-white"><tr></tr></thead>
<tbody></tbody>
</table>
[@endaftable](https://github.com/endaftable)
Or pass it directly:
[@livewire](https://github.com/livewire)('aftable', [
'model' => App\Models\User::class,
'columns' => [...],
'customTemplate' => '<table class="table table-hover my-theme" id="myTable">',
])
classCondition — no eval() (security fix)'classCondition' => [
// Closure — most flexible
'text-success fw-bold' => fn($row) => $row->active,
// String shorthand — truthy check on field
'border-primary' => 'featured',
// Negation shorthand — !$row->active
'text-muted' => '!active',
// Equality shorthand — $row->status === 'inactive'
'text-danger' => 'status:inactive',
],
How can I help you explore Laravel packages today?