diff --git a/README.md b/README.md index 2bc1490..c102094 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,187 @@ # Ginkelsoft DataTables -Ginkelsoft DataTables is a flexible and easy-to-use package for managing tabular data in your **Laravel** projects. It offers both a **base DataTable** for standard server-rendered apps and **Livewire integration** for dynamic, AJAX-driven experiences. With built-in support for filtering, searching, sorting, and bulk actions, it provides a quick way to build powerful data tables. +Ginkelsoft DataTables is a flexible and easy-to-use package for managing tabular data in your Laravel projects. It supports both a **base DataTable** class for traditional server-rendered apps and an **optional Livewire** component for dynamic, AJAX-driven experiences. You can easily add filtering, searching, sorting, and bulk actions with minimal setup. --- + +## Table of Contents + +1. [Requirements](#requirements) +2. [Installation](#installation) +3. [Usage (Without Livewire)](#usage-without-livewire) +4. [Usage (With Livewire)](#usage-with-livewire) +5. [Working with Actions](#working-with-actions) +6. [Additional Features](#additional-features) +7. [Contributing](#contributing) +8. [License](#license) + +--- + +## Requirements + +- **PHP 8.2+** +- **Laravel 10.0+** +- **Livewire** *(Optional, only if you need AJAX-driven data tables.)* + +--- + +## Installation + +1. **Require the package**: + + ```bash + composer require ginkelsoft/datatables:dev-main + ``` + +2. **Optionally register** the service provider if not using auto-discovery: + + ```php + // config/app.php + + 'providers' => [ + // ... + Ginkelsoft\DataTables\DataTableServiceProvider::class, + ]; + ``` + +3. **Publish the package views** (optional) for customization: + + ```bash + php artisan vendor:publish --provider="Ginkelsoft\\DataTables\\DataTableServiceProvider" --tag=views + ``` + +--- + +## 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 | +|
|---|---|---|
| {{ $row->id }} | +{{ $row->name }} | +{{ $row->email }} | +