Hello,
I'm trying to use serverside datable loading with yajra/databale.
This my composer.json :
"require": {
"php": ">=7.0.0",
"baum/baum": "^1.1",
"bestmomo/laravel5-artisan-language": "^0.1.2",
"creativeorange/gravatar": "^1.0",
"fideloper/proxy": "~3.3",
"intervention/image": "^2.4",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"maatwebsite/excel": "~2.1.0",
"yajra/laravel-datatables": "^1.0"
php --version : PHP 7.0.18-1~dotdeb+8.1 (cli) ( NTS )
I add to config/app.php :
'providers' => [
...
Yajra\DataTables\DataTablesServiceProvider::class,
],
'aliases' => [
...
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
]
And this is my controller file :
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Datatables;
use App\Article;
use App\Base;
class Test extends Controller
{
public function index()
{
return view('article.table');
}
public function data(Datatables $datatables)
{
$builder = Article::query()->select('id', 'base_id', 'gencode', 'size', 'colorLib');
return $datatables->eloquent($builder)
->editColumn('id', function ($user) {
return '<a>' . $user->id . '</a>';
})
//->addColumn('action', 'eloquent.tables.users-action')
->rawColumns([1, 5])
->make();
}
}
After long hour google i tried all of this command :
$ php artisan vendor:publish --tag=datatables$ composer dump-autoload$ php artisan config:cache$ php artisan cache:clearbut i still have this error :
ReflectionException
Class Datatables does not exist
Can anyone have a solution or know how to force to recognize the datatable class ?
i'am sorry for my english, i'm not very fluent.
Advance thanks guys ;)
The problem is you are adding the alias as
'aliases' => [
...
'DataTables' => Yajra\DataTables\Facades\DataTables::class,
]
But accessing the alias as
use Datatables;
which is wrong
use it like this
use DataTables;
There are breaking changes on v8. See upgrade guide for ref. Thanks!
Most helpful comment
The problem is you are adding the alias as
'aliases' => [ ... 'DataTables' => Yajra\DataTables\Facades\DataTables::class, ]But accessing the alias as
use Datatables;which is wrong
use it like this
use DataTables;