A
A
Abc Edc2016-02-09 08:53:54
Laravel
Abc Edc, 2016-02-09 08:53:54

Which part of the application is responsible for filtering the input?

The data comes by submit, so cutting off unnecessary trash on the client by interrupting the submit is not very convenient.
Both empty data (allowed by validation) and superfluous data come to the controller. They are superfluous for the manager to which the data comes after the controller. So who should take care of discarding and transforming data? the controller to adjust under the manager? manager for himself? Or can get DTO special for this purpose?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrzej Wielski, 2016-02-09
@gleber1

What exactly do you mean by "manager"? I have never seen such a concept in Laravel.
Laravel is based on the MVC architecture. Explanation - Model View Controller.
The logic for working with data is as follows:
In the view we display all the data, and the form for filling in the data.
View sends a POST request, route handles it, Request receives it, controller handles validation.
If there are no problems, the controller generates a request to the model (creating a new object), adjusting the incoming data as needed.
As soon as the data is saved, we display it on the desired page from the model.
In the model, in addition to connecting to the database, links are configured (hasOne/Many, belongsToMany, polymorphic links), scope functions are assigned (functions for processing and putting data in order from the model), and that’s it.
Of course, the model plays a slightly larger role when using various kinds of packages (slugable, sortable, searchable, etc.) - but the main function is the connection with the database, and the formation of data for the view.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question