Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jairocarrera's avatar

yajra Laravel Datatables

I want use yajra server side package with the sample code:

$users = User::select(['id','name','email','created_at','updated_at']);

return Datatables::of($users)->make();

I get an "Insuficient parameters" error.

Looking in the implementation of the library, I found the exceptions is thrown because:

public function isLegacyCode($request) { if ( ! $request->get('draw') && $request->get('sEcho')) { throw new \Exception('DataTables legacy code is not supported! Please use DataTables 1.10++ coding convention.'); } elseif ( ! $request->get('draw') && ! $request->get('columns')) { throw new \Exception('Insufficient parameters'); } }

the request is inyected to constructor:

public function __construct(Request $request) { $this->request = $request; $this->isLegacyCode($request); }

I don't know what I'm doing wrong ...

0 likes
15 replies
yajra's avatar

Hi guys, are you trying to access the data url directly? If yes, then you need to pass the parameters like ?draw=2&columns%5B0%5D%5Bdata%5D=0&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=.... This parameters are automatically added by DataTables JS library.

3d8872f30f6d29f809fdd78fc4512ca0's avatar

I can't speak for everyone else, but I'm not trying to access the data url directly. I'm simply trying to call the Datatables facade in my controller and it's throwing this error.

jairocarrera's avatar

@yajra I just call the Facade on the controller in this way: $users = User::select(['id','name','email','created_at','updated_at']);

return Datatables::of($users)->make();

the problem seems that the class is trying to get parameters (draw, colum) from the request as if called from the url.

I'm using Laravel 5

elsteno's avatar

Update: its ok! it was my fault! Sorry :)

same problem here! thanks

I'm using Laravel 5.1

jekinney's avatar

Looks like your query is wrong.

Try:

$users = User::select(['id','name','email','created_at','updated_at'])->get();

Or for a cleaner way

$users = User::get(['id','name','email','created_at','updated_at']);
// all() may work too, but not tested as I generally don't use all().
olibode's avatar

I've got exactly the same problem on one machine not the other - running the same code. I'm using Laravel 5 - having a lot of trouble figuring this out.

3d8872f30f6d29f809fdd78fc4512ca0's avatar

Okay, I fixed it.

The error was being thrown when I was trying to return the Datatables instance with my other view variables, it doesn't work that way.

To fix it, I created a separate function in my controller that is solely responsible for returning the Datatables instance. Then, I set up a route in my routes file that points to the function. The Javascript in the view that initializes the table looks something like this:

$(document).ready(function() {
    $('#example').dataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "route/to/datatables/function"
    } );
} );

I'm not the first person to make this mistake, and I know I won't be the last. Hopefully this will help someone else having the same issue.

1 like
yajra's avatar

Sorry guys, haven't checked laracasts lately and just saw this today. I just published a new Quick Starter Tutorial on demo site. Hopefully, this will help new users avoid the confusion.

siewwp's avatar

For "DataTables warning request unknown parameter id for row 0" please check UsersController is created or not.

If fix the error after I create the UsersController as below.


php artisan make:controller UsersController --plain

shanmca's avatar

install quick adminpanel laravel5.3 this error display

what sol:

Problem 1 - laraveldaily/quickadmin 2.0.0 requires yajra/laravel-datatables-oracle ^6.18 -> satisfiable by yajra/laravel-datatables-oracle[v6.18.0, v6.18.1, v6.18.2, v6.19.0]. - laraveldaily/quickadmin 2.0.1 requires yajra/laravel-datatables-oracle ^6.18 -> satisfiable by yajra/laravel-datatables-oracle[v6.18.0, v6.18.1, v6.18.2, v6.19.0]. - laraveldaily/quickadmin 2.0.2 requires yajra/laravel-datatables-oracle ^6.18 -> satisfiable by yajra/laravel-datatables-oracle[v6.18.0, v6.18.1, v6.18.2, v6.19.0]. - yajra/laravel-datatables-oracle v6.18.0 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0]. - yajra/laravel-datatables-oracle v6.18.1 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0]. - yajra/laravel-datatables-oracle v6.18.2 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0]. - yajra/laravel-datatables-oracle v6.19.0 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0]. - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system. - Installation request for laraveldaily/quickadmin ^2.0 -> satisfiable by laraveldaily/quickadmin[2.0.0, 2.0.1, 2.0.2].

To enable extensions, verify that they are enabled in those .ini files: - /etc/php/7.0/cli/php.ini - /etc/php/7.0/cli/conf.d/10-mysqlnd.ini - /etc/php/7.0/cli/conf.d/10-opcache.ini - /etc/php/7.0/cli/conf.d/10-pdo.ini - /etc/php/7.0/cli/conf.d/15-xml.ini - /etc/php/7.0/cli/conf.d/20-calendar.ini - /etc/php/7.0/cli/conf.d/20-ctype.ini - /etc/php/7.0/cli/conf.d/20-curl.ini - /etc/php/7.0/cli/conf.d/20-dom.ini - /etc/php/7.0/cli/conf.d/20-exif.ini - /etc/php/7.0/cli/conf.d/20-fileinfo.ini - /etc/php/7.0/cli/conf.d/20-ftp.ini - /etc/php/7.0/cli/conf.d/20-gettext.ini - /etc/php/7.0/cli/conf.d/20-iconv.ini - /etc/php/7.0/cli/conf.d/20-json.ini - /etc/php/7.0/cli/conf.d/20-mbstring.ini - /etc/php/7.0/cli/conf.d/20-mcrypt.ini - /etc/php/7.0/cli/conf.d/20-mysqli.ini - /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini - /etc/php/7.0/cli/conf.d/20-phar.ini - /etc/php/7.0/cli/conf.d/20-posix.ini - /etc/php/7.0/cli/conf.d/20-readline.ini - /etc/php/7.0/cli/conf.d/20-shmop.ini - /etc/php/7.0/cli/conf.d/20-simplexml.ini - /etc/php/7.0/cli/conf.d/20-sockets.ini - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini - /etc/php/7.0/cli/conf.d/20-sysvsem.ini - /etc/php/7.0/cli/conf.d/20-sysvshm.ini - /etc/php/7.0/cli/conf.d/20-tokenizer.ini - /etc/php/7.0/cli/conf.d/20-wddx.ini - /etc/php/7.0/cli/conf.d/20-xmlreader.ini - /etc/php/7.0/cli/conf.d/20-xmlwriter.ini - /etc/php/7.0/cli/conf.d/20-xsl.ini You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

Please or to participate in this conversation.