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

specific columns #19

Closed
bitcodr opened this issue Apr 5, 2018 · 5 comments
Closed

specific columns #19

bitcodr opened this issue Apr 5, 2018 · 5 comments

Comments

@bitcodr
Copy link

bitcodr commented Apr 5, 2018

How can i get specific columns in DingoQueryMapperBuilder

code like below :

        $orders = Order::whereNotNull('id');

        $qm = new DingoQueryMapperBuilder($request);

        return $qm->createFromBuilder($orders)->paginate()
@johannesschobel
Copy link
Owner

Please don't use the DingoQueryMapperBuilder directly, but rather use the DingoQueryMapper..

$orders = Order::whereNotNull('id')->get();
$qm = new DingoQueryMapper($request);
$orders = $qm->createFromCollection($orders)->paginate();

Now you have a paginated collection of your orders.. If you want to filter by specific fields, you can call it via your Request like this:
```GET /endpoint?field=value`

See the readme file for more details

@johannesschobel
Copy link
Owner

You can do your normal Eloquent-Queries as known from Laravel.. Then you pass it to the DingoQueryMapper which applies further features (like sorting, filtering, whatever)..

$orders = Order::where(...)->where(...)->where(...)->get();
$qm = new DingoQueryMapper($request);
$orders = $qm->createFromCollection($orders)->paginate();

is completely valid..

@bitcodr
Copy link
Author

bitcodr commented Apr 5, 2018

But i don't want to fetch all record and add query after that
createFromCollection gets all records without query
I want to when adding a query on api like the blow ;

orders?name=x&lastname=y

query take just records with x name and y lastname

@johannesschobel
Copy link
Owner

I am very sorry, i really don't get what you mean / want..

@bitcodr
Copy link
Author

bitcodr commented Apr 5, 2018

But my apis query strings are dynamic
Cannot add static where on Eloquent-Queries for the dynamic queries

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

No branches or pull requests

2 participants