laravel-datatables: Laravel Datatables.net get Class datatables does not exist error

after install this package on laravel i get this error:

ReflectionException in Container.php line 738: 
Class datatables does not exist

Install:

composer require yajra/laravel-datatables-oracle

configuration on app.php:

'providers' => [
    ...
    yajra\Datatables\DatatablesServiceProvider::class,
],

'aliases' => [
    ...
    'Datatables' => yajra\Datatables\Datatables::class,
],

run publish command:

php artisan vendor:publish

route:

Route::get('profitsData', 'ReportProfitsController@data');

controller:

namespace App\Http\Controllers;
use Yajra\Datatables\Datatables;

class ReportProfitsController extends Controller
{
    public function data()
    {
        return Datatables::of(User::select('*'))->make(true);
    }
}

‍‍‍``` composer dump-autoload

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

If someone come to this post using datatables 8 take into consideration that the package namespace was updated from Yajra\Datatables to Yajra\DataTables. with an UpperCase T.

I found this was fixed by changing “minimum-stability” to “stable” from “dev” because composer was trying to pull in “6.0.0-alpha” instead of the latest stable “6.20.0”. Maybe this will help.