Laravel 5.4 shipped with two new middlewares called
TrimStrings middleware – automatically trim all the request data.
ConvertEmptyStringsToNull middleware- automatically convert all strings to null.
Trim Strings Middleware
As the name implies, this middleware removes extra spaces from the beginning and ending from request data automatically. For example, if a user submits something like this.
With the presence of this middleware
App/Kernel.php, it gets converted into.
Its removed extra space.
Just as the name suggests, this middleware converts empty strings to null. If a user submits an empty form instead of getting
'' it gets converted to
If the user submits a form with a not required field that maps to the nullable database column.
With the presence of this middleware (\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class) in App/Kernel.php, it gets converted into.
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.