Home > Backend Development > PHP Tutorial > MySQL table defaults to null, but what is the correct way to handle the incoming null value in laravel?

MySQL table defaults to null, but what is the correct way to handle the incoming null value in laravel?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-03-01 15:14:01
Original
1674 people have browsed it

There are a lot of forms that are text, because they need to be handwritten, and the fields are int and null by default, so you don’t need to fill them in.

If you do not fill it in when inserting, an error will be reported. Because there are a large number of such fields, where is the best way to handle them?

Reply content:

There are a lot of forms that are text, because they need to be handwritten, and the fields are int and null by default, so you don’t need to fill them in.

If you do not fill it in when inserting, an error will be reported. Because there are a large number of such fields, where is the best way to handle them?

If you want to save effort, just overload the save function of the model

Traverse all the attributes inside, unset all empty string values, and then call the save function of the parent class

The default value of int type is 0

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Composer cannot install laravel
From 1970-01-01 08:00:00
0
0
0
Laravel Space/laravel-backup cannot be installed
From 1970-01-01 08:00:00
0
0
0
Laravel 5.1 Login laravel comes with it No more
From 1970-01-01 08:00:00
0
0
0
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template