V
V
vism2017-10-28 13:20:05
Laravel
vism, 2017-10-28 13:20:05

What is the best way to keep filtering/sorting on the page after saving/updating?

The essence of the problem.
Regular CRUD. On the page filters, sorting. Need to remember filters/sorting after editing, creating, etc.
The options I see.
1) Filters to the session - the most obvious and the most shitty coding, with problems with support.
2) URL with get parameters to the session - As far as I understand, there is no out-of-the-box support in Laravel. URL::back() and so on works for 1 transition, and if there were errors during editing and the page was reloaded or several pages of step-by-step editing, returning to the page index does not work, the back contains the wrong URL
3) open in another tab - not a user friendly.
Question.
Maybe there is an excellent, working pattern for solving this problem. Maybe a handy component.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
ThunderCat, 2017-10-28
@ThunderCat

Yes, I also thought, somehow on the frontend, but this is not a modern product) rendering everything and everything through the server every time

vism , cookies, and nothing prevents when requesting from cookies to get a variable that you would pull from the database / session. In addition, the session binds these settings to the current connection, while cookies will be available after relogin. To store such things in the database is a rare thing, these are display settings, and I can change them depending on the device from which I access the server, it's much more convenient. one view is convenient from a mobile phone, another from a desktop, in most cases.

A
Alexander Talalaev, 2017-10-28
@neuotq

And how do you remember the personal data of the user? For example Name, or password?
Here is the same approach. Make a table with saving user settings.
By the way, this is one case when it is convenient to store in json format, postgres even has a special field for this, however, in mysql you can store in text / strings, you are unlikely to use these fields for searching.
And when loading the page, just parse json (it's probably more convenient to use it if you actively use js and ajax), or read all the values ​​from the corresponding table and place them in the template engine.
The json table / structure itself is selected based on how your fields are generally released, see also here . This mechanism, for example, is actively used by the guys from Spatie, for example, in their product Laravel Permission , where there is a problem when you don’t know where to what type values ​​​​will be hung up.

A
Alex-1917, 2017-10-30
@alex-1917

In such cases (when I don’t know something) I go and mess with the engine, for example, if for a store, then I take a couple of store ones and gut, and here Lara is not clear at all))) write the settings for the list of goods in the database ???? ooooooo
We take opencart - the standard template looks - if it is in the session - it takes it from there, if not it looks in the localstorage, if it is neither there nor there, then it writes again checking whether the session or localstorage is available, i.e. awesome universal scheme and without any database)))
Bitrix - writes either to the session or cookies or to LS - 100% envy of the
HostCMS template - LS
I still don’t understand why it was advised to store it in the database above ??? logged in from the same device - cookies or LS right there! - ALL!

A
Alexander N++, 2017-11-16
@sanchezzzhak

Storejs if you think to save the filter through js

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question