-
-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom engines (eg for mongodb) #1294
Comments
On version 8, I am also trying to create an engine for Laravel Scout. See https://github.com/yajra/laravel-datatables-scout for reference for possible implementation. |
Will you be changing the general engine interface in v8 as well, like removing the One way to keep the interface more uniform would be by adding a magic __call/__callStatic method like the following pseudo code (basic principle is the same as laravel's // Datatables.php
public function __call($method, $parameters)
{
$engines = $config->get('datatables.engines');
if (!isset($engines[$method])) {
throw new BadMethodCallException("Method {$method} does not exist.");
}
return $engines[$method]::getInstance($parameters);
} Then you would only need to add your engine to the config.engines (and builder) array and you could just do Only difficulty with this solution i see currently is that e.g. jenssegers/mongodb extends the Eloquent classes, so the |
The interface would remain the same. The only major breaking change is the namespace and class name being updated from I was also thinking on how to implement |
For my project I am using mongodb through laravel-mongodb. Unfortunately I couldnt get laravel-datatables to work with mongodb, as laravel-mongodb requires different syntax in the QueryBuilderEngine as it does not use sql.
To still use mongodb I've written a rough mongodb engine for datatables. But as it seems at the moment there is no easy way of adding a custom engine to datatables, I had to completely exend the laravel-datatables project and e.g. overwrite all methods where configuration settings are pulled.
As this implementation is very ugly and difficult to maintain, do you have any recommendations how to better add a custom engine for mongodb?
The text was updated successfully, but these errors were encountered: