diff --git a/README.md b/README.md
index 8d5f3d8..4cd675c 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ Ginkelsoft DataTables is a flexible and easy-to-use package for managing tabular
## Requirements
- **PHP 8.2+**
-- **Laravel 10.0+**
+- **Laravel 10.0+**
- **Livewire** *(Optional, only if you need AJAX-driven data tables.)*
---
@@ -30,7 +30,7 @@ Ginkelsoft DataTables is a flexible and easy-to-use package for managing tabular
1. **Require the package**:
```bash
- composer require ginkelsoft/datatables:dev-main
+ composer require ginkelsoft/datatables
```
2. **Publish the package views** (optional) for customization:
@@ -41,60 +41,6 @@ Ginkelsoft DataTables is a flexible and easy-to-use package for managing tabular
---
-## Usage (Without Livewire)
-
-For a traditional server-rendered app:
-
-```php
-use Ginkelsoft\DataTables\DataTable;
-use Ginkelsoft\DataTables\Column;
-use App\Models\User;
-
-public function index()
-{
- $query = User::query();
-
- $datatable = (new DataTable($query))
- ->setColumns([
- Column::make('id', 'ID'),
- Column::make('name', 'Name'),
- Column::make('email', 'Email'),
- ])
- ->setPerPage(10);
-
- $rows = $datatable->getRows();
-
- return view('users.index', compact('rows'));
-}
-```
-
-And in `resources/views/users/index.blade.php`:
-
-```blade
-
-
-
- | ID |
- Name |
- Email |
-
-
-
- @foreach($rows as $row)
-
- | {{ $row->id }} |
- {{ $row->name }} |
- {{ $row->email }} |
-
- @endforeach
-
-
-
-{{ $rows->links() }}
-```
-
----
-
## Usage (With Livewire)
If you prefer an **AJAX-driven** workflow with real-time sorting, searching, and pagination:
@@ -104,8 +50,8 @@ If you prefer an **AJAX-driven** workflow with real-time sorting, searching, and
model="App\\Models\\User"
:columns="['id', 'name', 'email']"
:actions="[
- ['label' => 'Edit', 'route' => 'users.edit'],
- ['label' => 'Delete', 'route' => 'users.destroy']
+ ['label' => 'Edit', 'route' => 'users.edit', 'class' => 'bg-blue-500 hover:bg-blue-600 text-white px-2 py-1 rounded', 'style' => 'margin-right: 5px;'],
+ ['label' => 'Delete', 'route' => 'users.destroy', 'class' => 'bg-red-500 hover:bg-red-600 text-white px-2 py-1 rounded']
]"
:bulkActions="[
'delete' => ['label' => 'Delete', 'route' => 'users.bulk.delete'],
@@ -127,18 +73,20 @@ You can now:
### Row Actions
-Specify row-level actions in your Blade:
+Actions now support custom **classes** and **styles** for better UI customization:
```blade
:actions="[
- ['label' => 'Edit', 'route' => 'users.edit'],
- ['label' => 'Delete', 'route' => 'users.destroy']
+ ['label' => 'Edit', 'route' => 'users.edit', 'class' => 'bg-blue-500 hover:bg-blue-600 text-white px-2 py-1 rounded', 'style' => 'margin-right: 5px;'],
+ ['label' => 'Delete', 'route' => 'users.destroy', 'class' => 'bg-red-500 hover:bg-red-600 text-white px-2 py-1 rounded']
]"
```
+These actions will be rendered as buttons with the specified styles.
+
### Bulk Actions
-For bulk actions (like deleting multiple rows) set `:bulkActions`:
+For bulk actions (like deleting multiple rows), define them as follows:
```blade
:bulkActions="[
@@ -157,6 +105,8 @@ When multiple rows are selected, the component redirects to the specified route
- **Filter Class** for custom filters (status, categories, etc.).
- **Sorting Class** for ascending/descending ordering.
- **Select All** (with confirmation modal) to choose between only visible rows or all rows.
+- **Custom Actions** now support custom classes and inline styles.
+- **Prevent row selection when clicking an action button**, ensuring that clicking an action does not check the row checkbox.
---
diff --git a/resources/views/vendor/datatables/actions.blade.php b/resources/views/vendor/datatables/actions.blade.php
new file mode 100644
index 0000000..6aa0c18
--- /dev/null
+++ b/resources/views/vendor/datatables/actions.blade.php
@@ -0,0 +1,10 @@
+
diff --git a/resources/views/vendor/datatables/datatable.blade.php b/resources/views/vendor/datatables/datatable.blade.php
index 27b95db..eb44464 100644
--- a/resources/views/vendor/datatables/datatable.blade.php
+++ b/resources/views/vendor/datatables/datatable.blade.php
@@ -1,53 +1,191 @@
-
- {{-- 🔍 Zoekbalk --}}
-
-
-
-
+
+
+
+ {{-- 🔍 Zoekbalk --}}
+
+ {{-- 🔍 Zoekbalk met knop --}}
+
+
+
+ {{-- Zoekknop --}}
+
+
+ {{-- Resetknop --}}
+
+
+
+
+
+ {{-- Selectie aantal resultaten per pagina --}}
+
+
+
+
+
+
+
+ {{-- ✅ Bulkactie dropdown - Alleen tonen als er rijen geselecteerd zijn --}}
+
+ @if(count($selectedRows) > 0)
+
+
+
+ @endif
+
+
- {{-- 📊 Datatable --}}
-
-
-
- @foreach($columns as $column)
- |
-
- {{ ucfirst($column) }}
- @if ($sortColumn === $column)
- {{ $sortDirection === 'asc' ? '▲' : '▼' }}
- @endif
-
- |
- @endforeach
- @if (!empty($actions))
- Acties |
- @endif
-
-
-
- @foreach($rows as $row)
-
- @foreach($columns as $column)
- | {{ $row->$column }} |
- @endforeach
- @if (!empty($actions))
-
- @foreach($actions as $action)
- {{ $action['label'] }}
+
+
+ {{-- Paginering --}}
+
+
+ Pagina {{ $rows->currentPage() }} van {{ $rows->lastPage() }} - {{ $rows->total() }} resultaten
+
+
+
+ {{-- Vorige knop --}}
+
+
+ {{-- ✅ Als er 10 of minder pagina’s zijn: toon paginanummers als knoppen --}}
+ @if ($rows->lastPage() <= 10)
+ @for ($page = 1; $page <= $rows->lastPage(); $page++)
+
+ @endfor
+ @else
+ {{-- ✅ Meer dan 10 pagina’s: gebruik een dropdown --}}
+
@endif
- |
- @endforeach
-
-
-
- {{-- Paginering --}}
-
- {{ $rows->links() }}
+
+ {{-- Volgende knop --}}
+
+
+
+
+ @if($showSelectAllModal)
+
+
+
Selecteer alle rijen?
+
+ Wil je alleen de zichtbare rijen op deze pagina selecteren, of alle rijen in de database?
+
+
+
+
+
+
+
+
+ @endif
diff --git a/src/DataTableServiceProvider.php b/src/DataTableServiceProvider.php
index 2d091cc..6d86eae 100644
--- a/src/DataTableServiceProvider.php
+++ b/src/DataTableServiceProvider.php
@@ -16,8 +16,8 @@ class DataTableServiceProvider extends ServiceProvider
*/
public function register(): void
{
- // Load package views
- $this->loadViewsFrom(__DIR__ . '/Resources/views', 'datatable');
+ // Load package views from the correct
+ $this->loadViewsFrom(__DIR__ . '/../resources/views/vendor/datatables', 'datatable');
}
/**
@@ -32,9 +32,8 @@ public function boot(): void
{
// Publish views to allow customization
$this->publishes([
- __DIR__ . '/Resources/views' => resource_path('views/vendor/datatables'),
+ __DIR__ . '/../resources/views' => resource_path('views/vendor/datatables'),
], 'views');
-
// Register the Livewire component for the DataTable
Livewire::component('datatable', \Ginkelsoft\DataTables\Livewire\DataTableComponent::class);
}
diff --git a/src/Resources/views/datatable.blade.php b/src/Resources/views/datatable.blade.php
deleted file mode 100644
index eb44464..0000000
--- a/src/Resources/views/datatable.blade.php
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
- {{-- 🔍 Zoekbalk --}}
-
- {{-- 🔍 Zoekbalk met knop --}}
-
-
-
- {{-- Zoekknop --}}
-
-
- {{-- Resetknop --}}
-
-
-
-
-
- {{-- Selectie aantal resultaten per pagina --}}
-
-
-
-
-
-
-
- {{-- ✅ Bulkactie dropdown - Alleen tonen als er rijen geselecteerd zijn --}}
-
- @if(count($selectedRows) > 0)
-
-
-
- @endif
-
-
-
-
-
- {{-- Paginering --}}
-
-
- Pagina {{ $rows->currentPage() }} van {{ $rows->lastPage() }} - {{ $rows->total() }} resultaten
-
-
-
- {{-- Vorige knop --}}
-
-
- {{-- ✅ Als er 10 of minder pagina’s zijn: toon paginanummers als knoppen --}}
- @if ($rows->lastPage() <= 10)
- @for ($page = 1; $page <= $rows->lastPage(); $page++)
-
- @endfor
- @else
- {{-- ✅ Meer dan 10 pagina’s: gebruik een dropdown --}}
-
- @endif
-
- {{-- Volgende knop --}}
-
-
-
-
-
- @if($showSelectAllModal)
-
-
-
Selecteer alle rijen?
-
- Wil je alleen de zichtbare rijen op deze pagina selecteren, of alle rijen in de database?
-
-
-
-
-
-
-
-
- @endif
-