Laravel add values to request
23 February, 2022
Laravel add utility class
Programing Coderfunda February 23, 2022 Laravel, php No comments
4
1
# How to register utilities class on Laravel 5.8
2
# File: composer.json
3
# ref: https://stackoverflow.com/questions/28290332/best-practices-for-custom-helpers-in-laravel-5
4
"autoload": {
5
"classmap": [
6
...
7
],
8
"psr-4": {
9
"App\\": "app/"
10
},
11
"files": [
12
"app/helpers.php" // <---- ADD THIS
13
]
14
},
15
16
# Then run: `composer dump-autoload`
Source: stackoverflow.com
Laravel add user
Programing Coderfunda February 23, 2022 Laravel, php No comments
laravel add timestamps to existing table
Programing Coderfunda February 23, 2022 Laravel, php No comments
Laravel add request
Programing Coderfunda February 23, 2022 Laravel, php No comments
“laravel add request”
laravel add values to request
1
1
request()->request->add(['index'=>'value']);
laravel add request
2
1
$request->all() + ['index' => 'value'];
laravel get all request parameters
1
1
$request->input('name');
2
$request->input('user.name'); // fetch from user object
how to see with page reuested in laravel
0
1
$request->fullUrl()
2
The normal procedure is-
function storeDate(Request $request)
{
return $request->all();
}
This method will receive all the submitted field data from the web form.
Now, if you need to add extra data into request
array, you can add this way.
function storeDate(Request $request)
{
$authorName = 'Put your value here';
$myNewData = $request->request->add(['author' => $authorName]);
return $request->all();
}
Now you are able to access $authorName
in the request
array.
If you have more than one value you want to add, you can pass another value into the array like this way-
$myNewData = $request->request->add([
'author' => $authorName
'author2' => $authorName2
]);
Hope it will be helpful for you. Thank you.