getSearchResultsUsing() access other formdata
Hey,
Is it possible to access order data from the resource besides the $search string? For Example I would like to get only the search result for the selected brand,
Any suggestions?
11 Replies
Bumping this: how to access the other data from the form in getSearchResultsUsing()?
Is the brand a filter on the table or is the app scoped to the brand.
Better question, are you trying to update a table from a form. Or are you trying to simply filter a table?
The table is in the OrderResource in order to show order items. But you should only be able to select products from the supplier which has been selected when creating the order
You can adjust the table query with $table->modifyQueryUsing(). But I’m not sure where you’re going to get the supplier from to start with.
Maybe a select filter would be better than a search.
I have over 20k products to choose from.... So select filter is not an option really
Well, as long as supplier is a field on the column I would expect the search to filter it correctly.
You could make the select searchable. And preload it with like 25 options. To help with the db hit.
Unless you know the supplier upfront then modifying the table query up front isn’t going to do anything for you. It’s possible I’m misunderstanding you too.
I added a screenshot to make it more visual.
Now as you can see in the code below:
1. In the
options
I am able to filter the first chunk by the supplierId.
2. In the getSearchResultsUsing
I can in fact search for anything because it doesn't filter by supplier_id
I hope this helps to clarify my question.You don’t need options() and getSearchResultsUsing() and to restrict it to a a brand you just need to add the brand as another where() clause.
Ok. But how then, do i get the brand in the
getSearchResultsUsing
. In other words, how do I refer to the selected supplier in the where() clause?Depends on where you’re getting brand from. If it’s a separate filter you can get it from the query string. If it’s another field in this same filter form then you can use $get.
You would just have two where methods. They can be chained.
Ahhhhhh I didn't think
$get
would work in this closure. I always find it hard that when you are given the option to pass a closure, to see what can be passed as arguments.