PHP code example of logikinc / laravel-datatables-mongodb

1. Go to this page and download the library: Download logikinc/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/ */

    

logikinc / 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'      => Pimlie\DataTables\MongodbDataTable::class,
        'mongodb-query'  => Pimlie\DataTables\MongodbQueryDataTable::class,
        'mongodb-hybrid' => Pimlie\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 Pimlie\DataTables\MongodbDataTable;

return (new MongodbDataTable(App\User::where('id', '>', 1))->toJson()

use Jenssegers\Mongodb\Eloquent\Model;
use Pimlie\DataTables\Traits\MongodbDataTableTrait;

class User extends Model
{
	use MongodbDataTableTrait;
}

Route::get('users/data', function() {
	return User::dataTable()->toJson();
});