PHP code example of inprohub / laravel-datatables-mongodb
1. Go to this page and download the library: Download inprohub/laravel-datatables-mongodb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
inprohub / laravel-datatables-mongodb example snippets
/**
* Datatables list of available engines.
* This is where you can register your custom datatables engine.
*/
'engines' => [
// The Jenssegers\Mongodb classes extend the default Query/Eloquent classes
// thus the engines need to be listed above the default engines
// to make sure they are tried first
'moloquent' => Inprohub\DataTables\MongodbDataTable::class,
'mongodb-query' => Inprohub\DataTables\MongodbQueryDataTable::class,
'mongodb-hybrid' => Inprohub\DataTables\HybridMongodbQueryDataTable::class,
'eloquent' => Yajra\DataTables\EloquentDataTable::class,
'query-builder' => Yajra\DataTables\QueryDataTable::class,
'collection' => Yajra\DataTables\CollectionDataTable::class,
],
/**
* Datatables accepted builder to engine mapping.
* This is where you can override which engine a builder should use
* Note, only change this if you know what you are doing!
*/
'builders' => [
//Jenssegers\Mongodb\Eloquent\Builder::class => 'moloquent',
//Jenssegers\Mongodb\Query\Builder::class => 'mongodb-query',
//Jenssegers\Mongodb\Helpers\EloquentBuilder::class => 'eloquent',
//Illuminate\Database\Eloquent\Relations\Relation::class => 'eloquent',
//Illuminate\Database\Eloquent\Builder::class => 'eloquent',
//Illuminate\Database\Query\Builder::class => 'query',
//Illuminate\Support\Collection::class => 'collection',
],
use \App\MyMongodbModel;
$datatables = datatables(MyMongodbModel::all());
use Inprohub\DataTables\MongodbDataTable;
return (new MongodbDataTable(App\User::where('id', '>', 1))->toJson()
use Jenssegers\Mongodb\Eloquent\Model;
use Inprohub\DataTables\Traits\MongodbDataTableTrait;
class User extends Model
{
use MongodbDataTableTrait;
}