Skip to content
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

Extension #26

Closed
Plasto13 opened this issue Sep 16, 2020 · 5 comments
Closed

Extension #26

Plasto13 opened this issue Sep 16, 2020 · 5 comments

Comments

@Plasto13
Copy link

it is possible to add support for laravel Datatables and Laravel package for translatable models ???

@sebastienheyd
Copy link
Owner

Laravel Datatables is already supported. Have a look to my other package boilerplate-packager) that will help you to create package for boilerplate, if you generate one package you will see that datatables is used.

I'll take a look at the other package, it can be interesting in a project. However we don't have the use of it here because we don't have a model to translate in this package, or at least I don't see the use of it here.

The translation is more interesting if we create, for example, a package to manage multilingual articles, that's where we'll call it.

@Plasto13
Copy link
Author

I almost meant implementation as a service.
For better implementation of filtering, buttons, colReorder and much more in one class. I can imagine translatable models in a multilingual website with articles and can also be added to a datatable search.

public function applyScopes($query)
    {
        $request = request();

        $requestFilters = [];

        if ($request->has('filter_columns') && ($request->input('filter_table_id'))) {
            $requestFilters = [];
            foreach ($request->input('filter_columns') as $key => $column) {
                $requestFilters[] = [
                    'column'   => $column,
                    'operator' => $request->input('filter_operators.' . $key),
                    'value'    => $request->input('filter_values.' . $key),
                ];
            }
        }

        foreach ($requestFilters as $requestFilter) {
            if (isset($requestFilter['column']) && !empty($requestFilter['column'])) {
                $query = $this->applyFilterCondition($query, $requestFilter['column'], $requestFilter['operator'],
                    $requestFilter['value']);
            }
        }

        return parent::applyScopes($query);
    }

@sebastienheyd
Copy link
Owner

Maybe I don't understand the problem, for me datatables is already accessible as you can see here:

"yajra/laravel-datatables-oracle": "^9.0",
"yajra/laravel-datatables-html": "^4.0",

@Plasto13
Copy link
Author

Plasto13 commented Sep 17, 2020

Yes, I know. I almost thought to generate for each model to create a datatables class. To the Datatables directory. I have developed one class with additional javascript for working filters and bulk changes.
He is still in the proposal.
https://github.com/Plasto13/datatables/blob/master/TestDatatables
screenshot
I do this in asgardCSM. But he no longer goes to the higher version of Laravel

@sebastienheyd
Copy link
Owner

The version 7.10.0 comes with a new datatable component to generate a datatable with a class.

You can now generate your own datatable class with the artisan command boilerplate:datatable and easily build a datatable.

As you can see filters are automatically added. I will probably add more filter types in the future.

You can have a look to the UsersDatatable class as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants