append values to request array

How to “manually” add/append values to request array in laravel

Add/append values to request array in Laravel

I have encountered a situation where I needed to change the value of a particular request or append values to request array in Laravel before calling an Eloquent method in a store() or update() method with Request parameter. So I did search for how to do that and I will like to share my findings with you. Apparently, pretty easy.

Let’s look at the code for creating employee:

Changing the Date Format

The code above will create a new employee with the values entered in the form input fields. But what if you want to change the format of the date of employment input from the form. It will look like this:

Great? The general logic is to assign an array of key => value to the $request->request property.
Small tip, but I hope it is helpful!

How to Securely Set Laravel 5 Files Folders Permission and Ownership Setup

Clemence Ayekple

Let's grab a cup of coffee and talk about programming

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most discussed

%d bloggers like this: