yajra / laravel-datatables

jQuery DataTables API for Laravel

Home Page:https://yajrabox.com/docs/laravel-datatables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The yajra datatables can't be imported in laravel 7

daviddprtma opened this issue · comments

Summary of problem or feature request

Undefined type 'DataTables' in laravel 7

Code snippet of problem

image

public function dataSoal()
{
if (Auth::user()->roles == 'Guru' || Auth::user()->roles == 'Admin') {
$soals = Soal::where('id_user', Auth::user()->id)->get();
} else {
$soals = Soal::get();
}
return DataTables::of($soals)
->editColumn('waktu', function ($soals) {
return $soals->waktu . ' menit';
})
->editColumn('jenis', function ($soals) {
if ($soals->jenis == 1) {
return '

Ujian';
} else {
return 'Latihan';
}
})
->editColumn('kkm', function ($soals) {
return "" . $soals->kkm . "";
})
->addColumn('action', function ($soals) {
return '';
})
->rawColumns(['jenis', 'action', 'kkm'])->make(true);
}

System details

I don't know what's wrong with the version of yajra in laravel 7 because I did everything same as what the docs guide to me but it seem like the yajra couldn't be added in my controller. What I've been did like publish the vendor of yajra, clear the cache, do the config cache, edit the file in config/app.php especially in providers and aliases all I've been follow through the guide but I failed it. I can't do anything right now. Please help me because this datatable I needed for my thesis. Thank you.

  • Operating System: Windows 11
  • PHP Version: 7.3.31
  • Laravel Version: 7
  • Laravel-Datatables Version: ^9.21

Did you import the DataTable class accordingly?

I've been solved my problem just because I forgot to add jQuery Datatables in my blade file and now it's work. Anyway thank you for your reply @yajra