How to change value of a request parameter in laravel?

0 votes

I need to change value of my request parameter like this:

$request->name = "My Value!";

I use this code but does not work:

$request->offsetSet('img', $img);

How to change value of a request parameter in laravel?

Aug 10 in Laravel by kartik
• 27,140 points
75 views

1 answer to this question.

0 votes

Hello @kartik,

Use merge():

$request->merge([
    'user_id' => $modified_user_id_here,
]);

No need to transfer the entire $request->all() to another variable.

Hope it helps!!

Thank You!!

answered Aug 10 by Niroj
• 58,500 points

Related Questions In Laravel

0 votes
1 answer

How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?

Hello, To create both of the created_at and updated_at columns: $t->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); $t->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update ...READ MORE

answered Apr 2 in Laravel by Niroj
• 58,500 points
2,106 views
0 votes
1 answer

How to identify wheather the request is HTTP GET or HTTP POST in Laravel?

Hey, In order to identify the type of ...READ MORE

answered Mar 19 in Laravel by Niroj
• 58,500 points
91 views
0 votes
1 answer

How to mock a static facade methods in Laravel?

Hey, Facades provide a "static" interface to classes ...READ MORE

answered Mar 19 in Laravel by Niroj
• 58,500 points
495 views
0 votes
1 answer

How to check request is ajax or not in Laravel?

Hello, Laravel allow use of their library method that ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,500 points
193 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,500 points
2,168 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,500 points
236 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,500 points
189 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,500 points
2,680 views
+1 vote
1 answer

How to add a new column to existing table of laravel in a migration?

Hii @kartik, To create a migration, you may ...READ MORE

answered Mar 30 in Laravel by Niroj
• 58,500 points
10,092 views
0 votes
1 answer

How to get a list of registered route paths in Laravel?

Hello, Route::getRoutes() returns a RouteCollection. On each element, you can ...READ MORE

answered Mar 31 in Laravel by Niroj
• 58,500 points
210 views