It doesn't convert null to "null" by default, how are you retrieving that data? and how are you sending it?
Vuejs is converting "null" to string [ SOLVED ]
I need to get information from my database and some of that information is set to "NULL". However, I would like vuejs to take this as an empty string and not a "null" string.
For example, I take it like this:
name: this.user.name,
The name column is set to NULL, however vuejs converts this to a "NULL" string. How can I get the empty string?
I need to take it as empty because the validation of laravel doesn't work, since a string "NULL" is sent
@mvnobrega I would say the issue lies with Vuejs props, when you're calling this.user.site which may not exist in the database Vue doesn't know what to set this as when passing as a prop, is it a String, is it a number, an object etc
You should set your prop defaults so Vue knows how to handle the properties properly.
Alternatively, you could send the entire object as a JSON.stringify();
let formData = new FormData();
formData.append('avatar', this.avatar);
formData.append('userProps', JSON.stringify(this.cadastrar));
Then in your controller
public function updatePerfil(Request $request)
{
$userProps = json_decode($request->userProps, false);
$validated = Validator::validate($userProps, [
// Validation rules
]);
$avatar = $request->file('avatar');
//etc
//etc
}
Please or to participate in this conversation.