I want my datatables to process the data on the server side, I am referencing this example.
Server Side Example
However, the server side php class "ssp.class.php" given in this example uses core php with raw sql, I can not use it directly for laravel projects. Does anyone has reference to laravel way doing datatables. I don't want to use any packages at the moment though.
UPDATED 14 Oct 2023
You can use syamsoul/laravel-datatable-ssp package..
[Link here][2]
Open CLI and enter your app directory
Run this command composer require syamsoul/laravel-datatable-ssp
In your controller, you can follow the code below:
<?php
namespace App\Http\Controllers\Testing;
use App\Http\Controllers\Controller;
use SoulDoit\DataTable\SSP;
use App\Models\User;
class DatatableJsController extends Controller
{
public function index(SSP $ssp)
{
$ssp->setColumns([
['label' => 'ID', 'db' => 'id', 'formatter' => function ($value) {
return str_pad($value, 8, '0', STR_PAD_LEFT);
}],
['label' => 'Email', 'db' => 'email' ],
['label' => 'Username', 'db' => 'username' ],
['label' => 'Created At', 'db' => 'created_at' ],
]);
$ssp->setQuery(function ($selected_columns) {
return User::select($selected_columns);
});
return $ssp->response()->json();
}
}
This is working perfectly on Laravel 9 and above.
For more info, you can refer to the documentation site: https://info.souldoit.com/projects/laravel-datatable-ssp .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With