php_dvp
php_dvp

Reputation: 133

laravel 5 datatables collection not working

$data = array(
    ['name' => 'John Doe', 'email' => '[email protected]'], 
    ['name' => 'Robert Roe', 'email' => '[email protected]']
);
$users = new Collection($data);

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

I'm using the yajra/laravel-datatables plugin, it shows me that Collection functions are available on v5.x and later, but after i installed v5.11.10, and tried the above code, it gives me a Class 'Collection' not found error.

Upvotes: 0

Views: 2105

Answers (1)

David Stromberg
David Stromberg

Reputation: 244

Should be a namespace issue. Make sure:

use Illuminate\Support\Collection;

is included at the top of your controller.

Upvotes: 2

Related Questions