Get current filtered table sql? Save current component state with the filters? #1297
-
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
1 - After doing some digging on the source code I was able to figure out how to get the raw SQL of the current state of the grid.
$results = $this->datasource()
->where(
fn (EloquentBuilder|QueryBuilder $query) => \PowerComponents\LivewirePowerGrid\DataSource\Builder::make($query, $this)
->filterContains()
->filter()
);
dd($results->toRawSql()); 2 - I could see on the docs that I can make the grid to persist it's current state in a cookie. This feature is located at the PersistData trait, which is a pretty slick feature by the way. But the persistState and the restoreState functions have private accessors which doesn't give me ability to override this functionality to persist the state in the database instead of saving it in a cookie. That'd be nice if could override these methods. @luanfreitasdev would you be able to make these methods public? |
Beta Was this translation helpful? Give feedback.
1 - After doing some digging on the source code I was able to figure out how to get the raw SQL of the current state of the grid.
This is going to be useful for me, because I want my user to be able to save a query of the current filters the user have and that will bring a list of notifiables, that will allow me to reach out to the people on that resultset that the user has save accorting to his desire.
The code below was extracted from ProcessDataSource.php at processModel private function. I was able to copy the snippet to my descendant component and do what I needed.