What is phpmassassignment? What is php mass assignment? How can I translate mass assignment into Chinese?
Reply content:
What is php mass assignment? How can I translate mass assignment into Chinese?
In the past 12 years, this concept was first proposed in Ror. Later Laravel proposed this concept.
This means that when you create a new data entry in the database, there are unnecessary (not) update data without special code (filter) in this case, it may be maliciously updated (created ).
I think it can be translated:Batch assignment
Refer:
Ror;
Laravel's answer above;
The answer above StackOverFlow;
Special explanation;
Example:
Mass assignment is when you send an array to the model creation, basically setting> a bunch of fields on the model in a single go, rather than one by one, something> like:
$ User = new User (Input: all ());
(This is instead of explicitly setting each value on the model separately .)
You can use fillable to protect which fields you want this to actually allow for> updating.
Let's say in your user table you have a field that is user_type and that can have> values of user/admin
Obviusly, you don't want users to be able to update this value. in theory, if you> used the above code, someone cocould inject into a form a new field for user_type and> send 'admin' along with the other form data, and easily switch their account to an> admin account... bad news.
By adding:
$ Fillable = array ('name', 'Password', 'email ');
You are ensuring that only those values can be updated using mass assignment
To be able to update the user_type value, you need to explicitly set it on the model and save it, like this:
$ User-> user_type = 'admin ';
$ User-> save ();
Mass:
The masses and the masses; large-scale and centralized
Translate mass assignmentCentralized assignment
It is more appropriate.
P.s. LZ uses the Laravel framework, right? See http://stackoverflow.com/questions/22279435/what-does-mass-assignment -...
Laravel5 recently read this article. I usually do not translate.