A
A
Arman2020-01-17 11:21:27
Laravel
Arman, 2020-01-17 11:21:27

How do you work with bulk fill in Laravel?

https://github.com/alexeymezenin/laravel-best-prac... They
describe that bulk filling is very good and convenient, but how to decide what can be massively filled and what is not? Especially within multiple forms. Let's say:
1. There is a user form in the admin panel, where you need to let manage almost all fields: change login, full name, date of birth, etc.
2. The user form in your personal account, here you can give the fields to edit: About yourself, Education, etc., but you can’t edit the login, full name, date of birth.
In Yii, it was solved through scripts, but how? Prescribe all the fields, and then through the Request classes? Create repositories / services that will decide what can be filled through fillable ()? or?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
NubasLol, 2020-01-17
@NubasLol

through the Request classes

Yes. Validate each field and then$request->validated()

A
Alex Wells, 2020-01-17
@Alex_Wells

No, I don't use it at all. I just turned it off and fill it the way I want.

V
vism, 2020-01-17
@vism

Bulk filling is evil. Completely lost control over the data.
I never use.
In general, all this magic is supposedly beautiful, but in fact it is a "planted pig", maintaining all this magic is still that problem.
The code should be, first of all, as clear as possible completely without text comments, it should be easy to refactor and debug.
In general, his best practices are not bad, but this particular point is similar to 99% of articles about using repositories in Laravel. It is not clear who started the nonsense and is widespread by the Indians.
Update.
I see you also mentioned the repository, this infection has also affected you, do not succumb to it. Just learn what it is and why.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question